NextJS on Vercel, HTTP proxy not working (405 Method not allowed)

171 Views Asked by At

I followed this to proxy all requests from my NextJS app to a separate backend hosted at a different URL

Env vars are:

NEXT_PUBLIC_BACKEND_URL=/api
API_URL=https://other-host.com/api/v1

So, a request from the web app (that reads the URL from NEXT_PUBLIC_BACKEND_URL var),

such as POST /api/user/login { ...payload }

would be proxied to https://other-host.com/api/v1/user/login

It works on localhost

But not after deploying to Vercel

Am I missing some config or doing something wrong?

Thanks in advance!

Proxy HTTP requests to a different host, in a NextJS app deployed to Vercel

0

There are 0 best solutions below