Skip to content

Conversation

henrygr
Copy link
Member

@henrygr henrygr commented Oct 15, 2026

What was wrong

The site loaded at /project2/ but every asset 404'd. The SSR HTML references assets at /project2/assets/... (Vite base), but the Nitro server bakes its static-file routes from its own baseURL, which defaults to / — so it only served /assets/*, and Apache's passthrough proxy returned the Node server's 404.

The fix

  • Set the nitro plugin's baseURL to /project2/ in vite.config.ts, so the built server serves its public dir under the base
  • Add a route rule so /project2/assets/** keeps the immutable one-year cache header (Nitro's automatic rule is generated without the base)
  • Bonus: non-prefixed paths (e.g. /about, also produced by hardcoded links) now 307-redirect to /project2/about instead of 404

Verified against a fresh build

Request Before After
`/project2/assets/*.js css` 404
/project2/, /project2/about 200 200
/, /about 307 307 → /project2/…

Dev mode still works at localhost:3000/project2/. No Apache changes needed — the existing ProxyPass config is correct; this was purely on the Node side. Merging auto-deploys via the workflow.

* The SSR HTML references assets at /project2/assets/... (from the Vite
  base), but Nitro bakes its static file routes from its own baseURL,
  which defaults to "/", so every asset request proxied through Apache
  hit the Node server and returned 404
* Set the Nitro baseURL to /project2/ so the built server serves its
  public dir under the base; non-prefixed paths such as /about now
  redirect with 307 to their base-prefixed location
* Add a route rule so /project2/assets/** keeps the immutable one-year
  cache header, matching the automatic rule Nitro generates for /assets
@henrygr henrygr requested a review from a team as a code owner October 15, 2026 20:07
@henrygr henrygr self-assigned this Oct 15, 2026
@henrygr henrygr enabled auto-merge (squash) October 15, 2026 20:07
@henrygr henrygr merged commit de7325e into main Oct 15, 2026
1 check passed
@henrygr henrygr deleted the fix-ssr-asset-basepath branch October 15, 2026 20:11
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants