Next 9.5 redirection features not working
See original GitHub issueDescribe the bug I’m trying to use the new redirection features in Next 9.5, but they don’t seem to work with Serverless-Next.js. Specifically, trailing slashes and redirects. Are these not supported yet?
To Reproduce
I’ve added these options to next.config.js
:
const nextConfig = {
target: 'serverless',
trailingSlash: false,
// The main page is actually just a redirect
async redirects() {
return [
{
source: '/path',
destination: '/path/more',
permanent: true,
},
];
},
};
Expected behavior
These work as expected on the local dev server. http://localhost/path
redirects to http://localhost/path/more
, and http://localhost/path/more/
redirects to http://localhost/path/more
. However, deployed with serverless-next on AWS, these pages return 404 errors.
Versions
- OS: MacOS 10.15.5
- Node: 12.x (on AWS Lambda); 12.16.3 (local)
- Next: 9.5.1
- Serverless-Next: 1.17.0-alpha.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Blog - Next.js 9.5
Next.js 9.5 introduces Stable Incremental Static Regeneration, Custom Base Path, Redirects and Rewrites, Webpack 5 Beta, and more!
Read more >NextJS redirects not redirecting urls after define in next.config ...
In my case, I tried to redirect to external link. I had trailingSlash: true and I ended my source path with slash. It...
Read more >10 Next.js Tips You Might Not Know - Vercel
Tip 1: Next. Next. js Redirects are new to version 9.5 (released in July 2020) and give the ability to reroute an incoming...
Read more >[Solved]-Next.js Redirect from / to another page-Reactjs
First, you should asses whether you need client-side redirection (within React), server-side redirection (301 HTTP response) or server-side redirection + ...
Read more >HTTP Redirects <httpRedirect> - IIS - Microsoft Learn
HTTP Redirection is not available on the default installation of IIS 7 and later. ... In the Add Roles and Features wizard, click...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yep, they mentioned trailing slash so at least that one is supported now.
For custom redirect/rewrites/headers it looks like they have same underlying logic as they do path matching in similar way e.g with regex patterns. Seems like a good feature to add next, probably best to create general RFC/design doc for that so we do not have any perf issues, I can try to consolidate that later this week.
I created a PR for trailingSlash support: https://github.com/serverless-nextjs/serverless-next.js/pull/556