How to redirect to the URL originally tried to access in Static Web Apps?

matsunotsuma 0 Reputation points
2024-09-19T22:24:19.8466667+00:00

I'm developing React Web Site with SWA.

And I use Entra ID for authentication.

My site can redirect to log in by staticwebapp.config.json like below,

    "responseOverrides": {
        "401": {
        "statusCode": 302,
        "redirect": "/.auth/login/aad"
        }
    }

but after logged in, redirect to route address of my site.

But I want to be redirected to the URL originally tried to access.

For example,

current situation:

https://mysite.com/authenticated/address

https://mysite.com/.auth/login/aadhttps://mysite.com

desired outcome:

https://mysite.com/authenticated/address

https://mysite.com/.auth/login/aadhttps://mysite.com/authenticated/address

How can I this?

Best Regard.

Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
921 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
21,585 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.