fridays / next-routes

Universal dynamic routes for Next.js
MIT License
2.47k stars 230 forks source link

Going directly to a route (i.e., entering a deep-link URL directly) results in 404 #25

Closed ghost closed 7 years ago

ghost commented 7 years ago

If I have a route like:

/foo

or

/foo/bar

And I try to type that directly into the URL field of a browser rather than clicking a link generated in the website, I get a 404.

ghost commented 7 years ago

Actually...it may be that next-routes is not handling the routes. It looks like none of the next-routes route handling code is running. That might be my bad. Trying to figure it out.

fridays commented 7 years ago

Sounds like the routes handler was not properly included on the server side. Please post the relevant server part if it's not resolved yet.

confuser commented 7 years ago

Had this issue as well. I felt a bit silly, it was because I was still trying to use npm run dev (which just executesnext), instead of running node server.js.

ghost commented 7 years ago

@fridays That's exactly what the issue was. Sorry to have bugged you. @confuser I felt the same way after discovering it. Though, to be fair, in many ways it looked like everything else was working...or partially working so I didn't even consider this possibility. All good now though. Thanks guys! Works great in fact!

captainill commented 7 years ago

@ccuilla @confuser I just ran into this but I don't understand why I can't use npm run dev. I think it'd be helpful to know why it doesn't work. Can you enlighten me? Thanks!

ghost commented 7 years ago

@captainill Basically it's because you are overriding the server (from next.js) and creating your own. So you need to run that server instead by doing something like node server.js.