I’m trying to set up role-based folder access using Netlify Identity by following the guide Role-based access control with JWT. I’m on the Starter plan.
My _redirects
file looks like this:
/posts-gated/* 200! Role=subscriber
/posts-gated/* /login 302
However, the redirects are not working entirely as expected, for example:
- https://netlify-11ty-supermaya-test.netlify.app/posts-gated/page-does-not-exist – redirects to /login if logged out; 404 if logged in as subscriber
- https://netlify-11ty-supermaya-test.netlify.app/posts-gated – as above (folder has no index.html)
- https://netlify-11ty-supermaya-test.netlify.app/posts-gated/user-generated-content – shows the page whether logged in or not. Should only show if logged in as subscriber, otherwise redirect to /login
Can anyone advise?
Cheers.
~~EDIT: Ok, noticed that https://netlify-11ty-supermaya-test.netlify.app/posts-gated/user-generated-content is working as expected but not when you add a trailing slash: https://netlify-11ty-supermaya-test.netlify.app/posts-gated/user-generated-content/~~
EDIT 2: When I click on the link with the trailing slash in my previous edit, it works as expected. However, if I paste the URL https://netlify-11ty-supermaya-test.netlify.app/posts-gated/user-generated-content/
directly in the browser the content is visible when logged out.
EDIT 3: There seems to be inconsistency. If I repeatedly paste https://netlify-11ty-supermaya-test.netlify.app/posts-gated/user-generated-content/
in the Safari address bar and press Enter, it sometimes incorrectly lets me access the content and other times not. Other browsers behaving as per original description.