Support Forums

Role gated pages on localhost

Netlify CLI.

Using _redirect file to set up gated content. It works when deployed , but running netlify dev I cannot get it to work.

basic example of the redirect file would be

/private /private 200! Role=admin
/private /login 302!

I have admin role account I’ve set up on the netlify that works when site is deployed. The gated content is gated correctly and I can access it when I log in. Locally I cannot, after the log in its like my account is missing the admin role. Even though in local storage when I check I see I have the admin role in roles.

Hi @vorci

Welcome to Netlify

Have a look at this thread that outlines the same (albeit without roles) problem and links to an open GitHub issue.

Thanks for the reply. Unfortunately I couldnt find anything related to my issue on the links you’ve provided.

I suppose another question would be, how do people test/debug gated content locally? Does it usually work? Or do we accept the fact we need to deploy in order to test it out.

I believe RBAC was fixed in this PR: fix(command-dev): role based redirects by erezrokah · Pull Request #1545 · netlify/cli · GitHub, so it should work.

Also to confirm, the name of the file is _redirects and not _redirect. Possibly a typo?

Thanks for the reply.
Yes the _redirects is correctly named. I would like to note again that locally redirects work, the issue that does not work is that my account that Im logged in with ( which has admin role assigned to it ) is not recognized as admin locally, so content that is gated I cannot access with that adming role account. But when deployed it is.

hi there vorci, thanks for explaining. we haven’t forgotten about you, and hopefully we will have some more information on this soon.