0

I have a Nuxt 3 application that is served via an Nginx proxy on a different domain. My application is working fine on my development environment, but I'm facing an issue loading client-side assets like JS, CSS, and SVG files when deploying to production.

The Nuxt application is running on http://app.example.com, and the Nginx proxy is serving it on http://exampledomain.com.

I get 404 errors when the client tries to download js files and images, and I want all links to them (like /_nuxt/entry.adbd2355.js, /icons/wb2-icons-sprite.svg#wb2-estate-chevron-down) to always include the full URL.

Has anyone encountered a similar issue or can provide any guidance on how to resolve this? Any help would be greatly appreciated.

I have tried setting the vite.base option in nuxt.config.js as follows

// nuxt.config.js
export default defineNuxtConfig({
  // ...
  vite: {
    base: process.env.NODE_ENV === 'production' ? 'http://exampledomain.com/' : '/'
  },
  // ...
});

1 Answers1

0

Have you tried specifying cdnURL in your nuxt config? It only works in production, so you don't need to specify process.env.NODE_ENV.

app: {
    cdnURL: 'http://localhost:8080'
},

Result is that request urls for files become http://localhost:8080/_nuxt/entry.26282b82.js in production

Anoromi
  • 106
  • 2