question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Next 9.5 redirection features not working

See original GitHub issue

Describe 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:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
dphangcommented, Sep 2, 2020

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.

1reaction
dphangcommented, Aug 22, 2020

I created a PR for trailingSlash support: https://github.com/serverless-nextjs/serverless-next.js/pull/556

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found