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

Support html5 history mode routing #1788

Merged
merged 1 commit into from
Jul 31, 2018
Merged

Support html5 history mode routing #1788

merged 1 commit into from
Jul 31, 2018

Conversation

snaptopixel
Copy link
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 🎉

Copy link
Member

@DeMoorJasper DeMoorJasper left a comment

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
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
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