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

Add fallback file for SPA sites #159

Open
Hona opened this issue Jan 24, 2024 · 4 comments
Open

Add fallback file for SPA sites #159

Hona opened this issue Jan 24, 2024 · 4 comments
Labels

Comments

@Hona
Copy link

Hona commented Jan 24, 2024

Imagine I am using Blazor WebAssembly.

It starts from an index.html file but I would like to open a route, e.g. /mypage which the SPA can handle.

Would be nice to add an option for a fallback file.

Otherwise, I've been loving this tool ⭐

@nabijaczleweli
Copy link
Collaborator

sorry bestie i have no clue what this means

@Hona
Copy link
Author

Hona commented Jan 30, 2024

Lets say you have 3 files in the webserver

  • a.html
  • b.html
  • c.html

if the user routes to localhost/b.html etc it routes as usual.

Assuming there is a 'fallback' route that is configured as 'a.html', if they route to localhost/d.html (the file isn't found) then the server returns 'localhost/d.html' -> 'localhost/a.html'

more reading:

https://laraveldaily.com/post/route-fallback-if-no-other-route-is-matched
https://medium.com/@codingthang/fallback-route-on-rails-e19be25383dd

@nabijaczleweli
Copy link
Collaborator

So this is "return a redirect instead of a 404"?

@thecoshman
Copy link
Owner

I would guess this could be added as yet another cli argumnet... you provide a file that you want to be auto-redirected to, and then a regex for what can 'detect' a 404 and instead server the redirect. This auto-redirect would obviously only kick in if the file that was directly requested wasn't found in the first place. Not sure how it would interact with serving index files.

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

No branches or pull requests

3 participants