Single page app and role based redirect

I’ve got a single page app which I’d like to protect with a role based redirect rule.
Individually, they both work:

I can handle the SPA push state with:

/* index.html 200

And I can handle the role based redirects with:

/* /:splat 200! Role=*

But I can’t seem to be able to combine both… Adding Role seems to prevent the shadowing and causes everything to be replaced by index.html, so for example this doesn’t work:

/* /index.html 200 Role=*
/* /:splat 200! Role=*

Because my js files, which exist, get replaced with the content of index.html…

Is this a limitation of the system or am I just not doing it the right way?

I don’t think you’ll want the second redirect at least not as you have it written - that says that /asset.png should be served by /index.html which would be problematic, right? Is there more than an index file in the repo? If so, the first one should do the trick, but you’ll want “something else” to do with the main content for unauthenticated visitors, as shown in this example:

/protected/* 200! Role=admin
/protected/* /unauthorized.html 404

Also note that role based redirects are only available with business accounts - are you using one? (cf Netlify Pricing and Plans)

One of my teammates has opened an issue with support about this. They determined it was currently not supported and there’s a feature request.

Are Role base redirects only offered with business accounts? Will they ever be offered as an add on?

hi there,

at present, role based redirects are, as mentioned above, only available for business accounts. It is possible that we may change the pricing structure at some point, but I don’t think it will happen in the near future. You can read more about current pricing and addons here:

What are some workarounds if I don’t have a business plan to still password protect one or two pages of a site?

hi JadeQuo, password protection is available for Pro plans, which are $49 a month, business is a tier higher - depending on your needs, maybe the pro plan would suffice?