Skip to content

fix: handle CORS preflight in reverse proxy during local dev#7164

Merged
alexanderMontague merged 2 commits into
Shopify:mainfrom
0xtlt:fix/reverse-proxy-cors-headers
May 12, 2026
Merged

fix: handle CORS preflight in reverse proxy during local dev#7164
alexanderMontague merged 2 commits into
Shopify:mainfrom
0xtlt:fix/reverse-proxy-cors-headers

Conversation

@0xtlt

@0xtlt 0xtlt commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Summary

The HTTP reverse proxy used by shopify app dev does not handle CORS preflight (OPTIONS) requests, which breaks cross-origin fetch calls from UI extensions (e.g. Customer Account extensions calling the app backend through the Cloudflare tunnel).

This PR intercepts OPTIONS requests at the proxy level and responds with the appropriate CORS headers, reflecting the client's Origin, Access-Control-Request-Method and Access-Control-Request-Headers.

Changes

  • http-reverse-proxy.ts: intercept OPTIONS before forwarding, respond 204 with CORS headers
  • http-reverse-proxy.test.ts: 2 new tests (preflight with headers + preflight without)

Fixes #7324
Related: #5660

@0xtlt 0xtlt requested a review from a team as a code owner April 2, 2026 15:34
@0xtlt

0xtlt commented Apr 2, 2026

Copy link
Copy Markdown
Contributor Author

I have signed the CLA!

@alfonso-noriega alfonso-noriega left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great fix! I would just ask you to please revert the lock file.

@0xtlt

0xtlt commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

@alfonso-noriega

Great fix! I would just ask you to please revert the lock file.

Thanks! I reverted the lockfile changes, the PR diff now only contains the reverse proxy fix and its tests :)

@0xtlt 0xtlt requested a review from alfonso-noriega May 7, 2026 12:17
@alfonso-noriega

Copy link
Copy Markdown
Contributor

@0xtlt can you review the linting errors? we will check the Knip failure as it seems not related to your code. Thanks!

@alexanderMontague

Copy link
Copy Markdown
Contributor

@0xtlt we can't update since this is a fork, you should just need to rebase and fix the linting errors. Thanks

@0xtlt 0xtlt force-pushed the fix/reverse-proxy-cors-headers branch from f9b674f to 5c549a8 Compare May 12, 2026 15:40
@0xtlt

0xtlt commented May 12, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! I rebased the branch on latest main and fixed the linting errors :)

Ping me if you need another action @alexanderMontague

@alexanderMontague alexanderMontague left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

@alexanderMontague alexanderMontague added this pull request to the merge queue May 12, 2026
Merged via the queue into Shopify:main with commit 3baf9a5 May 12, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: HTTP reverse proxy swallows OPTIONS requests — breaks CORS preflight for extensions

3 participants