-
Notifications
You must be signed in to change notification settings - Fork 30.6k
Description
What version of Next.js are you using?
10.0.5
What version of Node.js are you using?
15.5.0
What browser are you using?
What operating system are you using?
Linux
How are you deploying your application?
Describe the Bug
When trailingSlash is set, if using a catch-all route in rewrites, you need a trailing slash otherwise the paths will never match. This is likely to be problematic if you wish to proxy an external server which may not expect trailing slashes on every request.
It may be worth ignoring trailingSlash in rewrites altogether, because let's say you have trailingSlash NOT set, but you are proxying a server which does have it set (eg. Django in its default APPEND_SLASH = True configuration), then you end up with a redirect loop.
Expected Behavior
To Reproduce
// next.config.js
module.exports = {
rewrites: async () => [
{
// The following will not work (no match).
// Use `/api/:path/` and `http://localhost:8000/api/:path*/` instead to make it work.
source: "/api/:path*",
destination: "http://localhost:8000/api/:path*",
},
],
trailingSlash: true,
}