I've been working on a project where Azure AD authentication is needed. My problem is that I'm a novice.. After configuring my app service, creating an Azure AD application connected to a companies' Azure AD. I can without any issues log in with my companies' Microsoft account connected to Azure AD and use my application. Though only in incognito mode or after deleting cookies. Cause when my browser recognise I'm already logged in, I get straight into my frontend part of my application. Though when trying to fetch data from the web api, I get no data in return. In incognito mode or with cleaned up cookies, I get redirected to the companies' microsoft login page and popup, before redirected to my app. Where I then can fetch data from the web api.
I'm programming in react and .net 5 (newest version of asp.net core https://docs.microsoft.com/en-us/dotnet/core/dotnet-five). Where I started out with this template "dotnet new react -o "output folder", before publishing the whole code, (MVC) to my app service. Module .Net core, View React and Controller .Net core.
In my Azure AD application I've set up a web redirect url and not SPA, but doesn't seem to matter. When I've configured the need to log in through Active Directory in my app service.
How can I get my web api to recognise I'm already logged in like it recognise when I log in incognito?
Console at web adress: has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
get blocked request of https://login.windows.net/"url-adress"/oauth2/authorize?response_type=id_token&redirect.....
edit: When investigating the issue further, it could seem like it's an issue with being logged into multiple microsoft accounts from different Active Directories. The user trying to fetch from my backend isn't part of the Active Directory connected to my app service. Does anyone know of a good solution for multiple account issues? Or anything else I should look into?