-
Notifications
You must be signed in to change notification settings - Fork 1
fix: studio Vercel API routes returning HTML instead of JSON + CORS for temp domains #1052
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
Merged
+186
−23
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0fbdd7e
Initial plan
Copilot 8805506
fix: configure Vercel to serve API routes as serverless functions ins…
Copilot e95f3a9
fix: add CORS middleware for Vercel temporary/preview domain deployments
Copilot 399f602
fix: remove functions block from vercel.json to fix pre-build validat…
Copilot 76e66ad
fix: use same-origin API for all Vercel deployments and extract getVe…
Copilot 15073a5
fix: copy API serverless function into output directory for Vercel de…
Copilot a249322
fix: follow hotcrm Vercel deployment pattern for API function detection
Copilot ab6ad6a
fix: remove TS stub after esbuild bundle to prevent Vercel ERR_MODULE…
Copilot cfc2227
fix: use committed .js wrapper + separate _handler.js bundle to avoid…
Copilot 6886a92
fix: add createRequire banner to esbuild ESM bundle for Node.js built…
Copilot 1bc22cd
fix: add functions.includeFiles for native addons (better-sqlite3, @l…
Copilot 0fa5419
fix: copy native modules from monorepo root node_modules for pnpm str…
Copilot 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // Vercel Serverless Function — Catch-all API route. | ||
| // | ||
| // This file MUST be committed to the repository so Vercel can detect it | ||
| // as a serverless function during the pre-build phase. | ||
| // | ||
| // It delegates to the esbuild bundle (`_handler.js`) generated by | ||
| // `scripts/bundle-api.mjs` during the Vercel build step. A separate | ||
| // bundle file is used (rather than overwriting this file) so that: | ||
| // 1. Vercel always finds this committed entry point (no "File not found"). | ||
| // 2. Vercel does not TypeScript-compile a .ts stub that references | ||
| // source files absent at runtime (no ERR_MODULE_NOT_FOUND). | ||
| // | ||
| // @see ../server/index.ts — the actual server entrypoint | ||
| // @see ../scripts/bundle-api.mjs — the esbuild bundler | ||
| // @see https://github.com/objectstack-ai/hotcrm/blob/main/vercel.json | ||
|
|
||
| export { default, config } from './_handler.js'; |
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
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
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.
The CORS allowlist currently permits any
https://*.vercel.apporigin while also settingcredentials: true. This is very broad: any site hosted on Vercel’s sharedvercel.appdomain could make credentialed cross-origin requests and read responses, which is risky if the API uses cookie-based auth. Consider tightening this to only this project’s preview/branch domains (e.g., derive an allowed pattern fromVERCEL_PROJECT_PRODUCTION_URL/VERCEL_URL), or disablecredentialsfor the wildcard case and require explicit origins for credentialed requests. Also note thatAuthPluginis configured withtrustedOrigins(CSRF) that do not include this wildcard, so auth endpoints may still fail even if CORS succeeds unless the two allowlists are aligned.