I am trying two scenarios: 1. Redirection can take place from an external site to one of the pages of my site. I am trying to capture the external site name using document.referrer after this redirection, but it is empty. [ NOTE- I am redirected after Azure AD authentication.]
- Within my site ( post authentication - to be clear). I redirect from one page to another . And on the next page I am trying to get previous page URL by document.referrer. But here again, it comes as blank.
Please suggest how to achieve the previous page from where the redirection to current page has occurred using angular 2 typescript.
You could try putting the referrer in the
state
variable and reading back after AzureAD redirects back.For some info on the state variable and other params you can send, checkout this doc.
Microsoft also provide the code sample angular2-connect-rest-sample to demo calling the Microsoft Graph in Angular2.
In this code sample, we need to authentication with Azure AD first. So we can refer the code about the authentication in the Angular2.
However I got the issue like the redirect url is doesn't match when I try to login-in. After I change the code below, the code sample works well for me.
authHelper.ts
Please let me know if it helps.