Conversation
After Shopify#7164, app-dev answers OPTIONS itself and omitted Access-Control-Allow-Credentials, so credentialed cross-origin fetches failed. When Origin is present, include Allow-Credentials on the preflight response.
|
Thanks for fixing the credentialed-preflight regression from #7164 — flagging a security concern with the current approach before this merges. Reflecting the request's Concretely: Suggested fix: validate |
|
@Svector-anu Thanks for flagging this. You’re right that reflecting an arbitrary I changed the approach rather than adding a caller-origin allowlist to the CLI. The reverse proxy now forwards I verified that the current proxy forwards Against current This does mean the target application must handle preflight requests, but it keeps the CORS policy in the component that actually knows which origins are trusted. Does this address the concern you raised? |
The only issue I see on my end is that it completely reverses the change from this PR: #7164 Maybe to allow the fix from that previous PR, we could add a new CLI argument like |
WHY are these changes introduced?
Fixes #8259
After #7164, the app-dev reverse proxy began answering CORS
OPTIONSitself instead of forwarding them to the backend. That synthetic 204 includedAccess-Control-Allow-Origin/ methods / headers, but notAccess-Control-Allow-Credentials. Credentialed cross-origin requests that require preflight therefore fail before reaching the backend.WHAT is this pull request doing?
When the preflight request has an
Origin, includeAccess-Control-Allow-Credentials: trueon the proxy's OPTIONS response (still reflecting the concrete origin, never pairing credentials with*).@shopify/appHow to test your changes?
pnpm --filter @shopify/app exec vitest run src/cli/utilities/app/http-reverse-proxy.test.tsExpect 12/12. The OPTIONS cases assert:
Origin→Access-Control-Allow-Credentials: trueOrigin→ credentials header absentOptional manual check: run
shopify app devwith a frontend request that actually triggers preflight (e.g.POST+Content-Type: application/json+credentials: include). On main the OPTIONS preflight fails CORS; on this branch it succeeds (backend must still send credentials CORS on the actual response).Checklist
patchfor bug fixes ·minorfor new features ·majorfor breaking changes) and added a changeset withpnpm changeset add