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

SPA mode + basename feature gives match issue in dev and 404 error on build #8712

Closed
ajhaining opened this issue Feb 7, 2024 · 5 comments · Fixed by #8720
Closed

SPA mode + basename feature gives match issue in dev and 404 error on build #8712

ajhaining opened this issue Feb 7, 2024 · 5 comments · Fixed by #8720
Labels
bug Something isn't working feat:spa Issues related to SPA Mode package:dev vite

Comments

@ajhaining
Copy link

ajhaining commented Feb 7, 2024

Reproduction

Related to #8145

Dev build issue

  1. Go to https://stackblitz.com/edit/remix-run-remix-7qirzt
  2. Open terminal and see dev build fail with:
<Router basename="/test"> is not able to match the URL "/" because it does not start with the basename, so the <Router> won't render anything.

Production build issue

  1. Open terminal run npm run build and see:
Error: SPA Mode: Received a 404 status code from `entry.server.tsx` while generating the `index.html` file.

System Info

Template generated from SPA mode example using nightly build 0.0.0-nightly-f7c2827-20240207

Used Package Manager

npm

Expected Behavior

  1. Dev SPA mode works without having to set Vite's base value
  2. Production build for SPA works

Actual Behavior

  1. Dev SPA mode fails with:
<Router basename="/test"> is not able to match the URL "/" because it does not start with the basename, so the <Router> won't render anything.
  1. Production build fails with:
Error: SPA Mode: Received a 404 status code from `entry.server.tsx` while generating the `index.html` file.
@brophdawg11 brophdawg11 self-assigned this Feb 7, 2024
@brophdawg11 brophdawg11 added package:dev vite feat:spa Issues related to SPA Mode labels Feb 7, 2024
@brophdawg11
Copy link
Contributor

Ah ok yeah I bet this is a one line change to add the basename to the initial Request used to generate index.html in SPA mode. Feel free to give this a shot in your local node_modules or via patch-package and see if that does the trick. I'm logging off for the day but will look at this tomorrow - thanks for the issue!

https://github.com/remix-run/remix/blob/dev/packages/remix-dev/vite/plugin.ts#L1718

@ajhaining
Copy link
Author

I bet this is a one line change to add the basename to the initial Request used to generate index.html

This does the trick @brophdawg11

Added the patch to here: https://stackblitz.com/edit/remix-run-remix-bqalcj but for some reason it won't pick it up for the dev build on Stackblitz, but works fine on the prod build. Both work fine locally.

@brophdawg11 brophdawg11 linked a pull request Feb 8, 2024 that will close this issue
@brophdawg11 brophdawg11 added bug Something isn't working and removed bug:unverified labels Feb 8, 2024
@brophdawg11
Copy link
Contributor

Fixed in #8720

@brophdawg11 brophdawg11 added the awaiting release This issue has been fixed and will be released soon label Feb 8, 2024
@brophdawg11 brophdawg11 removed their assignment Feb 8, 2024
Copy link
Contributor

🤖 Hello there,

We just published version 2.7.0-pre.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Copy link
Contributor

🤖 Hello there,

We just published version 2.7.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@brophdawg11 brophdawg11 removed the awaiting release This issue has been fixed and will be released soon label May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feat:spa Issues related to SPA Mode package:dev vite
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants