Troubleshooting role based redirect in netlify dev

I’ve been looking through the support docs and confused on role based redirect. I’m looking to add this feature into my site and testing it locally with netlify dev (I have a hugo site).

The redirect rule is as follows:

/en/membership/coreskills/*  /en/membership/coreskills/:splat  200!  Role=CORESKILLS
/en/membership/coreskills/*  /en/membership  301!

When I try to go to a link under /en/membership/coreskills/, I get redirected back to the membership page. This behavior happens both when I’m logged in and logged out. The netlify cli output is

Redirecting /.netlify/non-existent-path to /en/membership

I removed the bottom rule and get redirected to page not found. The outcome is the same if I remove the :splat then the entire ‘to’ path altogether. This behavior happens both when I’m logged in and logged out. No cli output.

I removed the role condition, and I get a blank screen. The netlify cli gives the output

Rewrote URL to /en/membership/coreskills/coreskills-1/index.html

I change the rule to
/en/membership/coreskills/* /en/about 200!
and it also gives me a blank page with the netlify cli output

Rewrote URL to /en/about/index.html

Finally I change the rule to
/en/membership/coreskills/* /en/about 301!
and it redirects to the correct about page with the netlify cli output

Redirecting /en/membership/coreskills/coreskills-1/index.html to /en/about

Any idea on what is happening here? I see that identity knows that I am logged in with the correct role. What path does the 200 rule try to direct to?

Any help much appreciated

Thanks in advance

It’s not supported: [feature] local emulation of Netlify Identity · Issue #440 · netlify/cli (github.com) (and won’t be for a considerable amount of time).

CLI uses Netlify API and the API doesn’t send your site’s JWT secret, so CLI cannot verify if the decoded JWT is valid or not.

On the Enterprise plan, I think you can set a custom JWT secret, which could work.

1 Like