Skip to content

Conversation

StealthBadger747
Copy link
Contributor

This fixes the bad change I made in #317 where the build output was fixed, but pnpm run dev stopped working.

The explanation for behavior is as follows

  • Vite’s base is designed for the production build output. In dev, the middleware stack still assumes it is mounted at /. It intercepts only paths like /@vite/..., /@id/..., /src/..., etc.
  • When we set base = '/admin/' globally, every module request during dev showed up as /admin/@id/__x00__virtual:react-router/.... Because those paths no longer start with /@id/, Vite never sees them;
    the request falls through to the React Router/Hono layer.
  • Hono treats the URL as an application route, so we get errors such as “No route matches /admin/app/tailwind.css” and HMR stops working. You get this exact failure: CSS 404s and broken runtime modules.
  • To make /admin work in dev we’d have to wrap the entire dev server behind a proxy that strips the prefix before Vite sees it, or fork the Vite dev server to recognize prefixed paths. That’s doable but involves substantial custom middleware; the official Vite docs explicitly note that base only affects the build output.

By contrast, production and pnpm preview are fine with the prefix because they serve the built bundle (where every asset already carries /admin). So the workable compromise is:

  • Re-run the base rewrite only when command === 'build', so the production bundle ships with /admin.
  • Keep dev rooted at / so Vite’s middleware can catch /@id, /@fs, etc., and HMR keeps working.

Docs links:

This time I actually tested dev :)

@StealthBadger747
Copy link
Contributor Author

As a result of the tailscale dependency upgrade relying on Go 1.25.1 and nixpkgs-unstable not being quite up to date (see https://nixpk.gs/pr-tracker.html?pr=441125 for progress) I had to implement an overlay onto the go package.

@tale
Copy link
Owner

tale commented Sep 27, 2025

Please ensure that the overlay is removed when necessary.

@tale tale merged commit 341a0e8 into tale:next Sep 27, 2025
2 of 3 checks passed
@StealthBadger747
Copy link
Contributor Author

Will do

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants