Repository navigation
fix(dev): apply headers from route rules for static assets - #2814
Closed
peterthenelson wants to merge 7 commits into
Closed
peterthenelson wants to merge 7 commits into
peterthenelson wants to merge 7 commits into
Conversation
- These otherwise fail to be applied to public assets (see nitrojs#2749). - This change replies them redundantly in the other cases (where they were already being applied), but the alternative would require duplicating or reversing the URL / file path logic from the "send" package. fixes nitrojs#2749
peterthenelson
added a commit
to peterthenelson/fiolin
that referenced
this pull request
Oct 26, 2024
- Using nitro so that I can use the dev servers for local development and testing of the CSPs, and then it should make Cloudflare Pages deployments pretty easy. - Unfortunately I had to fix a bug in the nitro dev server; hopefully I can get nitrojs/nitro#2814 merged (or another approach to fixing it if the maintainers don't like that one). - Added functionality to run 3p scripts (you can test that this works by using the fake3p server--see README.md). - I think current version of CSPs has the properties I want, but I might need to change them when adding WASM.
Author
|
@pi0 let me know if there's anything else I should do before you review this. Also, thanks for all your work on the many unjs projects; I've been finding them really useful :) |
routeRules in dev serverrouteRules in dev server
routeRules in dev server
pi0
reviewed
Oct 31, 2024
Author
|
I had a followup question (see thread) before I make the requested changes. |
Member
|
Added tests, two issues:
|
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Member
|
Thanks for PR dear @peterthenelson and sorry left unattended. Moving to #3926 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
🔗 Linked issue
#2749
❓ Type of change
📚 Description
As detailed in the linked bug,
routeRulesfail to apply to public assets when using the dev server. The reason this happens is, IIUC, that the handler forrouteRulesruns in the reloadable worker (like the majority of the server logic), while the public asset serving happens locally in the app created indev-server/server.ts. Requests for public assets get served without ever proxying anything to the worker.I solve this by adding a handler to the dev server itself that partially duplicates some of the logic in
route-rules.ts. Some notes:routeRules. The actual handler in the worker also allows for redirects and proxying. It's not clear to me whether it makes any sense to apply those to public assets, and in the case of proxying, it requires the "localFetch" object.Anyway, it's totally possible I'm going about this the wrong way, but that's my reasoning for why I did it this way.
Resolves #2749
📝 Checklist