-
Notifications
You must be signed in to change notification settings - Fork 27.1k
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
Custom server Express doesn't match routes Express routes? #2710
Comments
When you click the |
@bresson, can you share your entire |
@unregistered Thanks for your answer and link. Have I misunderstood the Next.js 2.0 documentation and examples which discuss custom server routing? Here's a link to the example which I think documents the feature : https://github.com/zeit/next.js/tree/master/examples/custom-server-express @nickdandakis I'm only experimenting with the Next.js custom server example in the link above. The extent of my experimentation is trying to switch routing matches on the backend |
@bresson, I just cloned and ran that example. Works exactly as intended. Navigating to I now understand your question though. Using |
Okay so what you have to do is this: |
https://github.com/zeit/next.js/tree/master/examples/custom-server-express
Based on the documentation for custom-server-express, my understanding is the express backend can match income requests and render the appropriate assets. The example leads me to believe it would be possible to define routes using Express However, when any of the <Link .../> components displaying on a page is clicked, the browser will bypass the matching route on the backend and proceed directly to the catch all route.
For instance, in the custom-server-express example, the following request will match '/a' and respond with a rendering of the page at 'b'.
server.get('/a', (req, res) => { return app.render(req, res, '/b', req.query) })
However, the match never seems to occur on the backend. Am I mistaken in my understanding of the documentation?
The text was updated successfully, but these errors were encountered: