Can't get relative paths in `nuxi generate`
When generating a static page with
nuxi generate
, the resulting files all have absolute references to each other. How I can generate a page with relative paths so that the resulting folder can be uploaded anywhere?10 Replies
I tried
app.baseUrl: "./"
, but that doesn't change the output; app.baseUrl: "custom"
changes the output (but of course it's still absolute then).
I also tried app.buildAssetsDir: "./__custom"
, but that still results in an absolute path (/__custom/__custom
for some reason).I found this issue:
https://github.com/nuxt/nuxt/issues/13780#issuecomment-1397314850
But using
baseURL: "./"
does not seem to work in Nuxt 3?GitHub
nuxt3-rc generate and url is not relative Url · Issue #13780 · nu...
Environment Nuxt CLI v3.0.0-rc.0-27508091.78fcbcf 10:48:08 RootDir: /Users/mac/.webcode/gin-nuxt/web 10:48:11 Nuxt project info: 10:48:11 Operating System: Darwin Node Version: v16.14.0 Nuxt Versio...
Openend an issue here: https://github.com/nuxt/nuxt/issues/28624
GitHub
Building with
baseURL: "./"
doesn't result in relative paths, no ...Environment Locally: Operating System: Darwin Node Version: v20.9.0 Nuxt Version: 3.12.4 CLI Version: 3.12.0 Nitro Version: - Package Manager: [email protected] Builder: - User Config: - Runtime Modules: ...
You have to use a dot only (without slashes) as baseUrl.
I tried that and added the info to the issue. Using a dot only breaks generated subpages.
Yeah that doesn't sound to be nuxt related anymore.
It seems to be related to your hosting provider.
No, the resulting files are already broken locally. This is just a static build. E.g.
npx serve .output/public
will already not work correctly when using baseURL: "."
.
I guess it could be a Nitro issue and not Nuxt issue, I'm not yet very confident in knowing which thing does whatIt's hard to say without seeing your code. Your reproduction does exactly what it is supposed to do.
./
=> /
, thats why only .
results into relative paths which might work better depending on your provider. I can't tell why this breaks your subpages without seeing the issue.Sure. Just made a new StackBlitz that reproduces the issue.
https://stackblitz.com/edit/nuxt-starter-qum3vc
hybridherbst
StackBlitz
Nuxt - Starter (forked) - StackBlitz
Create a new Nuxt project, module, layer or start from a theme with our collection of starters.
Updated the issue with more info as well.