fix(vercel): proxy /api/* to GCP VM backend#10
Merged
Conversation
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).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
medcore-health.vercel.appwas 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
vercel.jsonwithrewrites: /api/(.*)→https://136-117-181-143.nip.io/api/$1so the browser keeps talking tomedcore-health.vercel.appwhile the backend stays on the GCP VM..vercelignoreso Vercel stops scanningapi/,server/,e2e/,test-results/,docs/. The legacyapi/[...all].tsVercel 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:
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.