Second (unrelated) question, this time on the react side.
- I'm using react-router-dom including the (new?) data-loaders feature (specifying the api calls for a route inside the router itself, so the page element only loads after the api call is back).
- Unfortunately this means that putting
around the page route element doesn't work - because before it tries to render the page (which would redirect the user to log in), it has already tried and failed to hit the API without auth.
- I tried putting
around my parent route (without a data loader) (
in the example below) - but this didn't work either - the data loader still fires first and creates an error.
- For now I have gone with catching the 401 from the fetch inside the data loader method, and then redirecting the to the signin page - but:
- When I tried using supertoken's redirectToAuth for this - 1) there is a glimpse of error before the redirect 2) the redirect after login doesn't work, it gets into a spiral of failed refresh token requests - only fixed with a hard refresh of the page (whereup everything loads ok) - it's as if the data loader isn't getting the token.
- So now I'm just using reacts 'redirect' to signin. Meaning it doesn't auto-redirect the user back to where they were headed before the redirect.