-
Notifications
You must be signed in to change notification settings - Fork 47
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 optional --fallback CLI option #167
Conversation
@alex996 thanks for the PR. Will get a review on this soon for you |
@alex996 that sounds good let's do that. The rest of the PR looks good |
@alallier Done. Both issues would be closed by this PR. |
@alallier Ok, I see your point. Amended the commit. |
Looks good, merging. Thank you @alex996 |
Hi! Awesome fix and thank you. How can I update to this version? Best regards <3 |
@AlexanderSopov it is published to npm, you can just follow the normal npm update procedures |
Closes #164 and #166. Introduces an opt-in
-f
or--fallback
command-line flag, which allows to serve up the start page as a fallback, when the requested route cannot be resolved. This is useful when developing a single-page app that handles routing client-side with HTML5 history API.Currently, non-resolvable routes such as
/about
or/blog/some-post
are falling throughserve-static
, which can't match them to a file, and thus returns a404
. When-f
flag is on,reload
will detect these routes, and respond withindex.html
(or custom start page when-s
is provided). The front-end (e.g.react
usingreact-router-dom
) can then take over the rendering based on the URL path.As a stretch goal we could also serve up
blog.html
in response to/blog
if the said file happens to exist.Inspired by
--history-api-fallback
inwebpack-dev-server
.