nuxt-hub / core

Build full-stack applications with Nuxt on CloudFlare, with zero configuration.
https://hub.nuxt.com
Apache License 2.0
993 stars 57 forks source link

Nuxt with baseUrl set does not work #356

Closed exophunk closed 3 weeks ago

exophunk commented 3 weeks ago

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.

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

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: https://github.com/unjs/nitro/issues/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

atinux commented 3 weeks ago

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 https://github.com/unjs/nitro/pull/2821