question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RC12: `vite.server.proxy` ignored in nuxt.config.ts

See original GitHub issue

Environment

  • 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:closed
  • Created a year ago
  • Reactions:9
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
P4sca1commented, Oct 19, 2022

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.

4reactions
bcspragucommented, Oct 19, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to config vite HMR port in Nuxt3 config? - Stack Overflow
The issue is caused by Vite (by default) using port :24678 and this being blocked by Docker, causing Vite to error out and...
Read more >
wheat (@wheatjs) / Twitter
Working on Vue, Vite, VueUse, and their ecosystems. ... Performance Improvements Strict Config Schema and Types Nitro Development Server Proxy We are ...
Read more >
@vue/compat | Yarn - Package Manager
Overview. @vue/compat (aka "the migration build") is a build of Vue 3 that provides configurable Vue 2 compatible behavior. The migration build runs...
Read more >
cannot read properties of undefined (reading 'call') vue
The bug brokes the build process, I think is something related to webpack or vue-server-renderer, the above output is the error throwed by...
Read more >
nuxt: Versions | Openbase
If you encounter "The request URL ... is outside of Vite service allow list" issue, try adding path to vite.server.fs.allow in nuxt.config ....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found