Add circuit JSON download endpoint for debug page#417
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting
| const circuitJsonDownloadUrl = new URL(ctx.url.toString()) | ||
| circuitJsonDownloadUrl.pathname = "/circuit_json" | ||
| circuitJsonDownloadUrl.searchParams.delete("debug") | ||
| if (ctx.compressedCode && ctx.fsMap) { | ||
| circuitJsonDownloadUrl.searchParams.set("circuit_source", "code") | ||
| } |
There was a problem hiding this comment.
Preserve /api prefix in circuit JSON download link
The download URL is built from ctx.url and then its pathname is overwritten with /circuit_json. Because ctx.url has already had the /api prefix stripped for internal routing, this produces a link to /circuit_json instead of /api/circuit_json. In the deployed Next.js environment the API handler only lives under /api, so clicking the link rendered on /api?debug=1 will 404 and never reach the new endpoint, even though the Bun test passes (it serves the handler at /). The generated URL should retain the original request’s path prefix or explicitly add /api/circuit_json so the download works in production.
Useful? React with 👍 / 👎.
Summary
Testing
https://chatgpt.com/codex/tasks/task_b_68ed34188e14832e9a3a4605e6d5e906