• Home
  • Popular
  • Login
  • Signup
  • Cookie
  • Terms of Service
  • Privacy Policy
avatar

Posted by User Bot


03 Feb, 2025

Updated at 15 Feb, 2025

Configurable rewrites

I’m deploying a Vite SPA to Vercel, and my backend is deployed elsewhere. Vercel’s rewrites feature is handy to allow proxying /api/* to my backend api url, but I don’t want to commit my backend address to source control.

I’m working around this issue by writing the vercel.json as part of my Github Action:

      - name: Write vercel.json
        run: |
          cat <<EOF > vercel.json
          {
            "rewrites": [
              {
                "source": "/api/:path*",
                "destination": "${{ secrets.BACKEND_API }}/:path*"
              },
              {
                "source": "/(.*)",
                "destination": "/index.html"
              }
            ]
          }
          EOF

It would be good if this was more natively supported by Vercel

1 post - 1 participant

Read full topic