I am trying to set up the routing with my next.js configuration. Whatever I tried so far did not produce the intended results. This is becoming confusing and frustrating for me, any help will be appreciated.
Here is what I want:
- url goes to
/
=>/index.js
- url goes to
/users/
=>/user/index.js
- url goes to
/users/[user-id]
=>/user/user.js
Here is what doesn't work:
module.exports = {
target: "serverless",
async rewrites() {
return {
afterFiles: [
{
source: "/users/",
destination: "/users/"
},
{
source: "/users/:path*",
destination: "/users/:path*"
},
{
source: "/:path*",
destination: "/:path*"
},
{
source: "/:else*",
destination: "/"
}
]
};
},
};