Skip to content

fix(vercel): proxy /api/* to GCP VM backend#10

Merged
Builder106 merged 1 commit into
mainfrom
chore/vercel-rewrite
May 28, 2026
Merged

fix(vercel): proxy /api/* to GCP VM backend#10
Builder106 merged 1 commit into
mainfrom
chore/vercel-rewrite

Conversation

@Builder106
Copy link
Copy Markdown
Owner

Problem

medcore-health.vercel.app was 404ing on every /api/* request — /api/auth/login, /api/auth/me, etc. Login surfaced this as a misleading "Invalid user ID or PIN." The static Vite bundle was deploying fine, but no rewrite was configured, so API calls fell through to the static handler.

Fix

  • Add vercel.json with rewrites: /api/(.*)https://136-117-181-143.nip.io/api/$1 so the browser keeps talking to medcore-health.vercel.app while the backend stays on the GCP VM.
  • Add .vercelignore so Vercel stops scanning api/, server/, e2e/, test-results/, docs/. The legacy api/[...all].ts Vercel function path is dead — Express + libSQL never worked on Vercel's ephemeral filesystem, which is why this project moved to a GCP VM in the first place.

Verify

GCP VM is healthy:

$ curl https://136-117-181-143.nip.io/api/health
{"ok":true,"service":"medcore-api",...}

After merge, the Vercel preview on this PR should let you log in with the demo creds (DOC-001 / 4242 etc.) — that confirms the proxy hop works end-to-end before the production deploy.

Tradeoff

Vercel edge → GCP us-west1 backend adds ~50–150 ms per API call. Acceptable for the prettier URL.

The auto-deploy on every push to main was building the Vite bundle but
shipping it without any /api/* rewrite, so every API request from
medcore-health.vercel.app fell through to the static handler and 404'd.
Login was failing with a misleading "Invalid user ID or PIN."

Add vercel.json with rewrite to https://136-117-181-143.nip.io/api/$1,
and .vercelignore so Vercel stops scanning api/ and server/ (the legacy
serverless function path is dead — Express + libSQL never worked on
Vercel's ephemeral filesystem).
@vercel
Copy link
Copy Markdown

vercel Bot commented May 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
medcore Ready Ready Preview, Comment May 28, 2026 3:11pm

@Builder106 Builder106 merged commit fad40d3 into main May 28, 2026
4 checks passed
@Builder106 Builder106 deleted the chore/vercel-rewrite branch May 28, 2026 15:27
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