Replies: 3 comments
-
I just hit this too. It's the second pain point I've felt with the |
Beta Was this translation helpful? Give feedback.
-
I just hit this as well. For an existing website that doesn't use the leading '/' for their server-side rendered pages, pre-rendering them should just not change how its routing works. And also as the poster says, it's a bit unexpected how accessing the same route in a document request vs client navigation request behaves differently. |
Beta Was this translation helpful? Give feedback.
-
I am now using https://github.com/rphlmr/react-router-hono-server to prevent this problem It uses Hono static server instead of express static, which handles trailing slashes correctly. It also removes the need for the |
Beta Was this translation helpful? Give feedback.
-
express.static
will always append a trailing slash to .html files, meaning/path
gets redirected to/path/
if/path.html
exists.This is different than normal react-router routes and it's unexpected and can cause serious issues with SEO.
The issues comes from this line: html
Given that this is a non configurable behaviourthe best fix would be to replace
express.static
with something else, for example sirv .Beta Was this translation helpful? Give feedback.
All reactions