Redirects with custom express server #16394
Replies: 1 comment 2 replies
-
I would consider it weird if it behaved the other way around. You're using a custom express server, and for some routes you pass them to the nextjs handler inside that express server. Now if the If instead of that express route you would be using nextjs api routes, they would be within the scope of nextjs routing and you could redirect to/from them. Maybe check if you actually need to rely on that express server at all. If you need to use the express server however, you can still handle rewites and redirects inside of that. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
We have problems getting redirects to work if the
redirect.source
url matches an already existing express route.Given the following redirect rule in next.config.js:
and the following server.js
The redirect from
/foo
to/foobar
only works if we remove this routeTo me it seems like redirects only happen AFTER route matching and only if it doesn't match an already existing route. This seems a bit weird to me, can someone shed some light on if we are using redirects in the wrong way?
Beta Was this translation helpful? Give feedback.
All reactions