-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Express middleware for History API fallback #303
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
Conversation
The Connect middleware has issues with dots in URLs due to how it redirects the request. The Express middleware is much simpler and leverages Request.sendFile (Express 4.8.0 or later) to serve a fixed file (index.html) only if the express.static middleware failed to find a file. No rewriting needed, no issues with special characters in paths.
I'm having the same problem with connect-history-api-fallback. |
Any update on this PR? It solves a problem I also have. Can I do something to help speed up the adoption of a fix? |
An alternative fix is to replace the
This will make any page with a dot in the /app path to be redirected to index.html (as it should be if it were not considered as a file) |
@ChrisJamesC thank you, that works for me! |
@sokra I'd consider this PR as the |
This is now fixed in |
So, is this PR still relevant after the fix in |
Closing this since it is now possible to do this as an option. This PR is a breaking change, and I don't think it's worth it. |
It would be helpful to mention what option we should specify @SpaceK33z |
Use the historyApiFallback: {
disableDotRule: true,
} I personally encountered issues with the rewrite rule--for some reason it changed the bundle that was used, which was really confusing. The symptom I observed was the hashes in my output files were different for the rewrite URLs; all the other URLs had the same hash in the output. Not sure why, may need to use the |
I tried with "disableDotRule: true" but disabled the other files as .js or .css, which made my vuejs project broke. The solution that I found was based on this link. was change this: To this: The trick is create a rewrite to every route that uses dot on it. |
The Connect middleware has issues with dots in URLs due to how it
redirects the request. The Express middleware is much simpler and
leverages Request.sendFile (Express 4.8.0 or later) to serve a fixed
file (index.html) only if the express.static middleware failed to find
a file. No rewriting needed, no issues with special characters in paths.
BTW there are no tests for this project so I would appreciate help in reviewing the change.