Fix a Bolt app on Vercel: 404 on reload, missing keys, login
The app works in Bolt, then breaks on Vercel. It is usually one of three things: the build did not get the backend keys, Vercel does not know the pages of the app or login still points to Bolt. The backend stays in Bolt Cloud or in your own Supabase project, so the app on Vercel only needs its keys and the right addresses.
The app cannot reach its backend
Open Environment Variables in the settings of the project in Vercel and add every name and value from your .env file. A Vite app reads them when it builds, so deploy again after you add or change them.
Vite puts every value that starts with VITE_ into the code that runs in the browser. The address and the public key of the backend belong there. A secret key never does.
A 404 error when you reload a page
A Bolt app is often a single-page app. Vercel does not know its routes, so reloading a page other than the home page gives a 404 error. Add a vercel.json file to the root of the project:
{
"rewrites": [{ "source": "/(.*)", "destination": "/index.html" }]
}Commit it and push. Vercel deploys again.
Login sends people back to Bolt
If people log in, login still sends them back to the Bolt address. For your own Supabase project, go to Authentication, URL Configuration. Set the Site URL to the Vercel address and add it to the Redirect URLs. For Bolt Cloud, change the same in the Authentication settings of the project in Bolt.
Changes from Bolt do not show up
Bolt syncs both ways, so changes from Bolt reach GitHub and Vercel deploys them. Pull before you edit somewhere else. If Bolt and GitHub change the code at the same time, Bolt keeps its version and overwrites GitHub.
Sources
- Bolt help center: GitHub integration
- Vercel docs: Vite on Vercel
- Vite docs: Env variables and modes
- Supabase docs: Redirect URLs