Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuxt with baseUrl set does not work #356

Closed
exophunk opened this issue Oct 29, 2024 · 1 comment · Fixed by nitrojs/nitro#2821
Closed

Nuxt with baseUrl set does not work #356

exophunk opened this issue Oct 29, 2024 · 1 comment · Fixed by nitrojs/nitro#2821
Labels
bug Something isn't working upstream

Comments

@exophunk
Copy link

Describe the bug
In Nuxt, you can specify the app.baseUrl config to run the app in a "subfolder". That does work well locally in dev mode and also when running via npm run build && nuxi start.

We run a reverse proxy to ONLY serve our app at domain.com/my-page/ (and everything else like domain.com is non-nuxt)

It does not work when deploying to hub.nuxt.com. It also does not work with vanilla cloudflare pages and it also does not work for netlify. So it's probably not a nuxt-hub only issue, but maybe there is a way how to configure this on nuxt-hub/cloudflare to make it work.

When adding a baseUrl like /my-page/ then website runs at domain.com/my-page. Nuxt also correctly requests all assets from there, e.g.

  • domain.com/my-page/_nuxt/abc123.js
  • domain.com/my-page/_nuxt/abc123.css
  • domain.com/my-page/my-images/logo.png

The problem is, that npm run build does not output _nuxt/ at that location but at the root. So you can actually open

  • domain.com/_nuxt/abc123.js --> status 200
  • domain.com/my-page/_nuxt/abc123.js --> status 404

We run a reverse proxy to ONLY serve our app at domain.com/my-page/, so you would never find the assets at the root. They should be correctly served from domain.com/my-page/_nuxt/abc123.js. Contents of dist should be found at domain.com/my-page/

There is an upstream issue here: nitrojs/nitro#1484
But I am not sure if this is something need to be configured on Hub/Cloudflare side.

Steps to reproduce
Steps to reproduce the behavior:

  1. Deploy an app with app.baseUrl set to non-empty, like /my-page
  2. See that the app does not work, as it won't find any asset.

Expected behavior

  • Contents of dist should be found at domain.com/my-page/
@atinux
Copy link
Contributor

atinux commented Oct 29, 2024

Thanks for reporting, I will investigate, I believe this is a bug yes as we should be able to tell Nitro that base URL too

Edit: just opened nitrojs/nitro#2821

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants