Repository navigation
Fix CORS preflight handling in the app dev reverse proxy #8803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Dylan-GJ
wants to merge
1
commit into
Shopify:main
Choose a base branch
from
Dylan-GJ:fix-app-dev-proxy-cors-preflight
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@shopify/app': patch | ||
| --- | ||
|
|
||
| Forward CORS preflight requests from the app dev proxy to your app, so credentialed requests work again |
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a preflight only passes with a 2xx that allows the origin, and this relays anything below 400. So besides Vite we'd also relay Express's automatic
200+Allow(for a path with routes), the auto-answers in Next.js route handlers, Flask and Django when the app has no CORS handling, and any 3xx (a redirected preflight is a network error). Auth middleware that redirects session-less requests will redirect every preflight, preflights never carry cookies orAuthorization.Those fail in production too, same as the 404 we already fall back on, so I'd treat them all the same. An OPTIONS without
Originisn't a browser preflight, so that 2xx can go through as-is:Apps that grant credentials for the origin still get relayed so #8259 stays fixed, and the fallback is the same 204 main sends today. Downside is that a deliberate allowlist "no" sent as a 2xx gets overridden for non-credentialed requests, same trade-off the doc comment already accepts for a 403.
Can we update that comment to the new rule? the PR description and the commit message also describe the 4xx/5xx rule