Redirect to the previous URL

There are 2 applications. Let’s assume as A and B. I will be launching with a particular route(http://localhost:4200/profile/:id) from A to B. In B, I will be redirected to the login page. After login, I need to redirect to the previous URL that I used A to hit B.

How do I achieve this scenario? I am uisng okta/okta-angular: “0.0.13”

If its SAML you should use relaystate parameter