Vercel Services monorepo - Expo Web (SPA) refresh results in 404

Hello! I am migrating my project to a monorepo setup using the new Vercel Services Beta.

My project has an Express backend (packages/server/) and an Expo Web frontend (packages/client/).

Everything builds successfully and routes perfectly when clicking links from the home page. However, performing a browser refresh on a nested route (e.g. /c/1234) triggers a Vercel 404: NOT_FOUND error.

Here is my root vercel.json configuration:

{
  "services": {
    "my_frontend": {
      "root": "packages/client/",
      "outputDirectory": "dist"
    },
    "my_backend": {
      "root": "packages/server/",
      "entrypoint": "src/index.ts"
    }
  },
  "rewrites": [
    { "source": "/api/(.*)", "destination": { "service": "my_backend" } },
    { "handle": "filesystem" },
    { 
      "source": "/((?!api).*)*", 
      "destination": { 
        "service": "my_frontend",
        "path": "index.html" 
      } 
    }
  ]
}

Any advice on how to correctly configure the SPA routing fallback for static service assets would be greatly appreciated!

There’s another community post with 404 debugging tips that might be helpful. Please give these solutions a try and let us know how it goes.

A human should be around soon to offer more advice. But you can also get helpful information quickly by asking v0.

If you’re having trouble deploying an Express app, this guide can help.

You can also ask v0 for suggestions tailored to your own project setup.