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.

Nuxt 3 Vite server proxy does not work after build

See original GitHub issue

Environment


  • Operating System: Darwin
  • Node Version: v16.14.2
  • Nuxt Version: 3.0.0-rc.3
  • Package Manager: yarn@1.22.18
  • Builder: vite
  • User Config: components, buildModules, typescript, css, plugins, unocss, runtimeConfig, vueuse, vite, build, nitro
  • Runtime Modules: -
  • Build Modules: @vueuse/nuxt@8.5.0, @pinia/nuxt@0.1.9, @unocss/nuxt@0.33.5

Reproduction

nuxt.config.ts vite: { server: { proxy: { "/proxy_path": { target: "https://domain.com", changeOrigin: true }, } } Screen Shot 2022-05-17 at 8 55 54 AM

Describe the bug

After run build success I’m start command node .output/server/index.mjs to preview build but it’s got an error (page not found). Note: Development work fine.

Screen Shot 2022-05-17 at 8 59 37 AM

Additional context

No response

Logs

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
danielroecommented, May 18, 2022

Setting a vite proxy only works in development; this is even true when not using Nuxt: https://vitejs.dev/config/#server-proxy.

Follow https://github.com/unjs/nitro/issues/113 for built-in proxy support in Nitro. Until then you can implement manually using Nitro server middleware.

0reactions
wiseadmecommented, Dec 3, 2022

FYI: I’d suggest to use Nitro’s devProxy instead

thank you, but it didn’t help either, I tried it before writing, only installing @nuxtjs-alt/proxy helped

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to configure proxy in Vite? - Stack Overflow
I was trying to follow the docs and created ...
Read more >
Server-Side Rendering - Vite
Vite provides built-in support for server-side rendering (SSR). The Vite playground contains example SSR setups for Vue 3 and React, which can be...
Read more >
Dev server proxy - Vue.js Developers
The solution is to proxy calls to the API server during development. Luckily, this is something that's easy to configure with the Webpack...
Read more >
Setting up proxy for localhost API testing, not working with vite
Cant seem to get the proxy server setup so I can avoid CORS errors when trying to hit my little node.js/express server on...
Read more >
Configuration - Nuxt
By default, the Nuxt development server host is localhost which is only accessible from within the host machine. In order to view your...
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