Site tweaks to improve strict CSP hosting #2492
Open
+31
−12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request
🤨 Rationale
The reason for this PR was trying to evaluate Nimble-based apps hosting in Web App hosting under our strict CSP policy. This was done by exercising the nimble site build which covers the following: Angular, Blazor, Vite, Storybook.
In doing so identified some changes that are either useful or minimally invasive as workarounds for WebApp hosting issues or improving the experience of Nimble site if hosted in Web App hosting.
👩💻 Implementation
Vite:
/script.js
) to relative paths in the current directory (./script.js
). Reason is WebApps are not hosted in root but from a subdirectory path.Angular:
Blazor:
<base href="./" />
. This is not compatible with our strict CSP setting and is ignored due tobase-uri: 'none';''
(the OWASP strict policy example) causing the errors to continue. We potentially could switch our CSP tobase-uri: 'self'
but it's not clear to me what the security implications are and I'm not recommending it yet (see following).index.html
based urls working, I'm not going to propose changes to Web App hosting strict CSP base-uri configuration to support the workaround described above. Instead, I think we should say Nimble Blazor WebApp hosting is contingent on Blazor 9 support in Nimble and fixing path serving in Web App hosting. I don't think we should recommend the workarounds I figured out above to Blazor WebApp devs as from the linked issues Blazor does not seem interested in supporting that pattern.Storybook:
All:
index.html
paths as it's minimally invasive (makes the URL bar uglier) but works around AzDo 2941644. This could be reverted in Nimble once the WebApp directory hosting issue is address.🧪 Testing
Manual and via built storybook.
Also example hosted on dev:
✅ Checklist