Skip to content

Hotfix: move proxy test out of src/pages (Pages build fail) - #62

Merged
neuromechanist merged 1 commit into
mainfrom
feature/hotfix-pages-stop-routing-test-file
May 23, 2026
Merged

neuromechanist merged 1 commit into
mainfrom
feature/hotfix-pages-stop-routing-test-file

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Root cause of the two failed prod deploys

PR #60 added src/pages/api/v1/proxy.test.ts next to [...path].ts. Astro treats every .ts file under src/pages/ as a route — the test file was being built as /api/v1/proxy.test with no GET/POST exports. Local bun run build silently accepted it as an empty route, but the Cloudflare Pages production build rejected the missing handler exports and failed. That's why the prod deploys for both #60 and #61 failed even though the PR-preview builds and local builds passed.

Verified in dist/_worker.js/index.js: pre-fix had two routes entries — "/api/v1/[...path]" AND "/api/v1/proxy.test". Post-fix only "/api/v1/[...path]" is built.

Fix

  • Extracted isSafeProxyPath to src/lib/proxy-path.ts (lives alongside other helpers, not in src/pages so Astro can't route to it).
  • Moved its test to src/lib/proxy-path.test.ts and updated the import.
  • The proxy route file (src/pages/api/v1/[...path].ts) now imports isSafeProxyPath from ../../../lib/proxy-path.
  • Added a JSDoc comment on proxy-path.ts explaining why the helper has to live in src/lib/ rather than next to the route.

Test plan

  • bun run typecheck — 0 errors
  • bun run test — 370/370 (same count; the test just moved)
  • bun run build — clean, and verified only /api/v1/[...path] is in the built route table (no /api/v1/proxy.test shadow route)
  • bun run lint — clean
  • After deploy: curl https://app.nemar.org/api/v1/datasets?mine=true returns 401 (proxy reaches backend, no cookie) — the original goal of PR Same-origin /api/v1 proxy for dashboard mutations (#59) #60 + Hotfix: /api/v1 is an app route, not marketing #61.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

@neuromechanist
neuromechanist merged commit a1d2c88 into main May 23, 2026
1 check passed
neuromechanist added a commit that referenced this pull request May 26, 2026
CF Pages picks up *.test.ts under src/pages/** as a route entry
and breaks the build (same class as PR #62 / commit 3cbc89f for
the proxy test). Relocate to src/lib/tree-endpoint.test.ts; the
file still imports GET from the route source, so the wire-contract
coverage is unchanged. 393/393 tests pass; local astro build
completes clean.
@neuromechanist
neuromechanist deleted the feature/hotfix-pages-stop-routing-test-file branch June 21, 2026 22:50
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.

1 participant