Repository navigation
Conversation
The proxy answered every OPTIONS request itself without Access-Control-Allow-Credentials, which broke credentialed cross-origin requests. Preflights now reach the target app, which decides CORS. The proxy only responds itself, without credentials, when the target answers with an error status or can't be reached.
4 tasks done
Author
|
I have signed the CLA! |
This branch has not been deployed
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
WHY are these changes introduced?
Fixes #8259
#7164 made the
shopify app devreverse proxy answer CORSOPTIONSrequests itself, because some dev servers don't handle them. The response never includesAccess-Control-Allow-Credentials, so credentialed cross-origin requests (fetch(..., {credentials: "include"})) fail the preflight even when the app's backend is configured correctly.Adding the header in the proxy isn't safe: it reflects any
Origin, so it would authorize every site. Reverting #7164 (see #8320) would bring back #7324 and #5660 for backends without anOPTIONShandler.WHAT is this pull request doing?
The proxy now forwards
OPTIONSrequests to the target app, which decides CORS, credentials included. The proxy only responds itself (same response as before, never with credentials) when the target answers with a 4xx/5xx status or can't be reached.Hop-by-hop headers are not relayed from the target's preflight response.
How to manually test your changes?
shopify app devwith a backend that answersOPTIONSwithAccess-Control-Allow-OriginandAccess-Control-Allow-Credentials: truefor a trusted origin. Send a preflight to the tunnel URL:curl -i -X OPTIONS -H "Origin: <trusted origin>" -H "Access-Control-Request-Method: POST" <tunnel url>/<path>The backend's headers, including credentials, are returned.
OPTIONShandler (returns 404/405). The proxy answers with a 204 reflecting the origin, withoutAccess-Control-Allow-Credentials.Checklist
patchfor bug fixes ·minorfor new features ·majorfor breaking changes) and added a changeset withpnpm changeset add