Nuxt Bridge app.baseURL doesn't work with i18n module
Environment
- Operating System:
Darwin - Node Version:
v14.18.1 - Nuxt Version:
latest - Package Manager:
[email protected] - Bundler:
Webpack - User Config:
- - Runtime Modules:
- - Build Modules:
-
Reproduction
nuxt.config.js
import { defineNuxtConfig } from '@nuxt/bridge'
export default defineNuxtConfig({
router: {
base: '/d/'
},
})
Describe the bug
The base path in nuxt bridge seems to be broken. If I set it to the above /d/ every preload link in the frontend is set to /d/d/ and all files are also reachable only with this path.
It seems the only url which is not affected by this is the one to the header js file in production

What makes the thing worse - because the file lies under /d/d/ and the whole site is broken
Additional context
No response
Logs
No response
@danielroe I made a mistake at my initial issue: /d is also not working. So the basePath property as a whole seems to be broken right now
To configure the base path with Nitro, don't configure router.base directly. Instead, you can pass NUXT_APP_BASE_URL or set app.baseURL.
For example:
yarn build
NUXT_APP_BASE_URL=/d node .output/server/index.mjs
Or:
import { defineNuxtConfig } from '@nuxt/bridge'
export default defineNuxtConfig({
- router: {
- base: '/d/'
- },
+ app: {
+ baseURL: '/d/'
+ },
})
Let me know if that resolves it for you.
@danielroe The assets are now resolved and are reachable under /d/. The problem now are the pages or precisely the i18n package.
We have a Cloudfront which routes all /d/ traffic to the lambda where the nuxt application is loaded. But without the router option <domain>/d/en/login is redirected to <domain>/en/login and therefore outside of the application.
The router option should be set dynamically based on the basePath. Perhaps you could share some reproduction code? 🙏
Sure I'll create a reproduction. Another thing I noticed:
The JS Files in `head` still seems to behave different than all the other nuxt files
Would you open an issue on https://github.com/nuxt-community/i18n-module? 🙏
The value of app.baseURL does not apply to ~static, while router.base does.
We were using ~static in img src attribute, e.g.
. It works fine during local development, but when we start nuxi build we have to switch from router.base to app.baseURL, which fixes the preload link issue, but created ~static issue again.
For now we have to abandon ~static and replace it with the global var baseURL, not quite elegant anyway.
I have the exact same issue with a nuxt/bridge even without using any third-party modules. When I define router.base with some value - let's assume /test/ for example - it gets doubled in the script routes embedded to the header. Any solution for this yet?
I was able to hard code _nuxt folder path using buildAssetsDir (it's not even documented!) - but I guess that's a pretty weak solution. Hope this issue will get addressed soon.
Same issue here.
yes - also had the problem that my fonts in /assets were not found - because the prefix was missing - the key was to specify the buildAssetsDir string as specified by @sweetpalma even though it should be the default anyway...(i also added baseURL and router.base but buildAssetsDir really made all the difference)
app: {
buildAssetsDir: '/_nuxt/'
}
I also had the same issue. I followed the work around by @sweetpalma and @saraha33. That fixed the issue. Thanks!
At least buildAssetsDir is now in the docs.