jaredpalmer / after.js

Next.js-like framework for server-rendered React apps built with React Router
https://npm.im/@jaredpalmer/after
MIT License
4.13k stars 201 forks source link

Potential bug with route matching #568

Open Yamaha32088 opened 9 months ago

Yamaha32088 commented 9 months ago

I am wondering if I have found a bug or if what I have found is the intended behavior. The bug I believe is the line below

https://github.com/jaredpalmer/after.js/blob/dbc362fa9b7204349e2d8fdc8c7ea4d80132faf7/packages/after.js/src/renderApp.tsx#L141

It passes in req.url instead of pathname like it does in this file

https://github.com/jaredpalmer/after.js/blob/dbc362fa9b7204349e2d8fdc8c7ea4d80132faf7/packages/after.js/src/loadInitialProps.tsx#L19

The problem is that req.url can contain a query string for example https://example.com/?testing=123 which would make req.url equal to /?testing=123 and it would never actually match a route. I discovered this after trying to figure out why the match property was null inside of the Document getInitialProps function. Can someone tell me if this is the intended behavior for some reason?

Yamaha32088 commented 9 months ago

I also believe it is duplicate work because the match object returned from the call to loadInitialProps should return the same thing.