Hi,
Is it possible to apply conditions to a SPA redirect?
For gated sites I use this redirect, which works fine:
[[redirects]]
from = '/*'
to = '/*'
status = 200
conditions = {Role = ["user"]}
If there is no session cookie, this redirects to a separate identity provider, which issues the required session cookie on a successful login.
[[redirects]]
from = "/*"
to = "/api/login?url=:splat"
force = true
status = 302
The redirect function handles the redirect to the identity provider.
However, with a SPA site I tried this:
[[redirects]]
from = '/*'
to = '/index.html'
status = 200
conditions = {Role = ["user"]}
This works in dev, but it does not seem to read the cookie and load the app home route when deployed.
I appreciate with a SPA app you can carry out auth checks in the router, but for consistency across static and spa sites it would be good to be able to protect the main app route with a role if possible.
I have tried a number of different combinations, having read the docs and answers in the forums re language conditions, but I can’t get it to work.
Thanks,
Paul