RC12: `vite.server.proxy` ignored in nuxt.config.ts
See original GitHub issueEnvironment
- Operating System:
Linux
- Node Version:
v16.13.1
- Nuxt Version:
3.0.0-rc.11
(note: I downgraded after rc12 broke things) - Nitro Version:
0.5.4
- Package Manager:
npm@8.1.2
- Builder:
vite
- User Config:
-
- Runtime Modules:
-
- Build Modules:
-
Reproduction
I can try to make a fresh reproduction if needed, but the issue is pretty straightforward: updating to RC12 makes Vite dev server proxying stop working. For example, we have a config like the following:
vite: {
server: {
proxy: {
'/api': {
target: 'http://localhost:8080',
},
},
},
},
We route any traffic at http://localhost:3000/api/...
to our backend, running on 8080. This has worked well in all Nuxt 3 versions up til now, and as far as I can tell, is still a valid and supported Vite option.
Describe the bug
As of RC12, our proxy config is no longer respected. Building on the example above, a request to http://localhost:3000/api/graphql
used to return a response from our backend server on http://localhost:8080
, but now hits our Nuxt catchall route and gives us a 404 page.
SSR requests succeed as usual (because they don’t use the proxy for backend requests), but any subsequent requests from the clients fail, because they’re getting an HTML response when they were expecting JSON.
Additional context
No response
Logs
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:9
- Comments:12 (4 by maintainers)
Top GitHub Comments
We are using a proxy configured with nginx in production and I used the vite dev server proxy in development to get the same result. So there are legitimate reasons to use the vite proxy.
Similar deal on our end: In production we use rewrites in Firebase Hosting to send traffic to the backend, so the proxying is only needed locally. We could use something like NGINX to do the proxying, but that’s another service to run when developing.