New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RC12: vite.server.proxy
ignored in nuxt.config.ts
#15195
Comments
I also had this problem, because I configured |
I also had this problem. Just try with fresh install and the issue is still here. |
Please do not use vite proxy. The vite dev server is not the same thing as the nitro dev server and they are not compatible. See #14917. edit: the change in behaviour is likely a result of new h3 format. (However, I think it's much more likely we want to make sure we support proxy natively in nitro than support vite proxy.) cc: @pi0 |
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. |
This comment was marked as duplicate.
This comment was marked as duplicate.
@danielroe Can you advise some additional solution of proxying locally? |
Not danielroe, but it turns out that our deployed app was broken (broken SCSS styling, didn't root cause it) on RC11, so I bit the bullet and updated to RC12 (which fixed the issue). My solution was an NGINX proxy in a Docker container, that I start up alongside my backend service (though it could be done independently or with the frontend). Here's how I did it, using the same config from above as an example:
The NGINX config looks like:
This config says "Run NGINX on port 3000, route traffic to anything at And then we run NGINX in Docker with:
The We then run (using
and run it in preview mode with:
I also had to turn off
As far as I can tell, this works flawlessly, including HMR in dev mode. |
@bcspragu thx so much for detailed answer. |
same |
With RC13, you can use Nitro's |
Closing as we now have |
Environment
Linux
v16.13.1
3.0.0-rc.11
(note: I downgraded after rc12 broke things)0.5.4
npm@8.1.2
vite
-
-
-
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:
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 onhttp://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
The text was updated successfully, but these errors were encountered: