opennextjs-netlify: Netlify's rewrite rule doesn't work with fallback pages

Describe the bug Netlify’s rewrite rule doesn’t work with fallback pages. It returns 404.

To Reproduce Steps to reproduce the behavior:

  1. Create next.js app with path like: /posts/:id with fallback: true
  2. Set rewrite rule in _redirects file /posts/:id/:slug /posts/:id 200
  3. Deploy to netlify
  4. Go to: /posts/1 -> page is rendered
  5. Go to: /posts/1/seo-friendly-name -> page is NOT rendered and we get 404

Expected behavior The fallback page is rendered correctly for rewrite rules.

Versions

  • Next.js: 10.1.3
  • plugin: 3.4.2

If you’re using file-based installation

  • netlify.toml:
[build]
  command = "next build"
  publish = "out"

[[plugins]]
  package = "@netlify/plugin-nextjs"

[context.production.environment]
  NEXT_SERVERLESS = "true"
  NODE_ENV = "production"

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 15

Most upvoted comments

per your report, we will log a warning to users who set revalidate in any of their pages to try to explain some of this so there are less invisible consequences to using revalidate on netlify. @surjithctly

@surjithctly yes, the issue is with the revalidate setting. https://github.com/netlify/netlify-plugin-nextjs/blob/main/docs/caveats.md#incremental-static-regeneration currently we SSR all revalidate pages, which is why you weren’t seeing your prerendered files in your publish dir at first. unfortunately it’s unclear at the moment how netlify plans to address revalidate, so i would just continue to follow there. our hope would be that, yes, the rewrite issue gets resolved whenever we add more/better support for revalidate, but as you can see on this issue, even for fallback pages, this issue can sometimes be unavoidable.