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/' : '/'
},
// ...
});