Skip to content

Support html5 history mode routing#1788

Merged
fathyb merged 1 commit into
parcel-bundler:masterfrom
snaptopixel:master
Jul 31, 2018
Merged

Support html5 history mode routing#1788
fathyb merged 1 commit into
parcel-bundler:masterfrom
snaptopixel:master

Conversation

@snaptopixel

Copy link
Copy Markdown
Contributor

While developing my first Parcel project I noticed that html5 history urls/routes were not working when reloading the page or changing the url manually. This is due to a default setting in serve-static which redirects directory urls to /. I made this simple change to my locally installed parcel-bundler and all works as expected 🎉

@DeMoorJasper DeMoorJasper left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this break Single Page Applications?

@snaptopixel

Copy link
Copy Markdown
Contributor Author

@DeMoorJasper this fixes SPAs 😄

Without this change, if you are using html5 history mode in an SPA and navigate to a route like:

http://localhost:1234/some/route

If you refresh your browser, or manually change the url, it will always redirect you to localhost:1234 losing the some/route part of the url.

This change will simply keep the url in place. It will still load the root index.html for the SPA and all should work as expected.

@DeMoorJasper

Copy link
Copy Markdown
Member

Ow alright, didn't expect that to happen from reading the docs. Thanks for this

@fathyb fathyb merged commit e4ec369 into parcel-bundler:master Jul 31, 2018
devongovett pushed a commit that referenced this pull request Oct 15, 2018
devongovett pushed a commit that referenced this pull request Oct 15, 2018
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.

3 participants