Attempting to use role-based redirect results in a 404 for Next.js app

Website: https://polite-malasada-3aad20.netlify.app/

I am deploying a static HTML Next.js site and am trying to do a redirect based on the user’s role.

Here is my netlify.toml file:

[build]
  command = "yarn build && yarn export"
  publish = "out"
  functions = "netlify/functions"

[functions]
  node_bundler = "esbuild"

[[redirects]]
  from = "/home/*"
  to = "/home/:splat"
  force = true
  status = 200
  conditions = {Role = ["personal", "elite"]}

Netlify deploy logs show that the redirect seems to be processed successfully:

However, attempting to navigate to Wires Only Club - Grow your business results in a 404. I can only get to that route if I use useRouter().push from Next.js.

I am using @netlify/plugin-nextjs": "^4.35.0" and "next": "13.3.0".

I have verified via the Netlify UI that the user does indeed have the correct role.

Any idea what might be happening here?

I don’t believe this will work as Next.js handles all routing.

While it doesn’t go into using roles, there is a recent article showing how to integrate Netlify Identity to Next.js on the Netlify blog

According to this Next.js redirects and rewrites on Netlify | Netlify Docs Netlify does support it. However, I followed that guide and am still having issues.

Is the page a dynamic one?

If you are using a rewrite that points to a dynamic Next.js page, you must use Next.js rewrites.

Also…

Is it a protected route? If so, I believe the integration outlined in the article is the way to go.

Is the page a dynamic one?

No, it’s a static HTML page.

Is it a protected route? If so, I believe the integration outlined in the article is the way to go.

What do you mean by protected route? I do not have anything configured in next.config.json

I’m not seeing the redirect you mentioned on your currently deployed site. Has something changed?