I just deployed a new web app, API, and DB to Azure. As a test, I had about six people use the app. It worked for five people, but one person got this CORS error:
SEC7120: [CORS] The origin 'https://mysite.azurewebsites.net' did not find 'https://mysite.azurewebsites.net' in the Access-Control-Allow-Origin response header for cross-origin resource at 'https://mysiteapi.azurewebsites.net/user'.
How is that possible? The architecture is like this:
Browser > Azure Web App > Azure API > Azure DB
The CORS issue is between the Azure Web App and the Azure API, right? So how could one person have this issue when nothing changes between the web app and the API for each user?
In my .NET Core 3.0 API, I have this
app.UseCors(options => options
.WithOrigins("http://localhost:4200", "https://localhost:4200", "https://mysite.azurewebsites.net")
.AllowAnyMethod()
.WithHeaders("Authorization", "Content-Type"));
And my web app calls the API like this:
const headers_object = new HttpHeaders().set("Authorization", "Bearer " + jwt);
this.http.get('user', { headers: headers_object, responseType: 'json' })
.subscribe((data: any) => {
this.userDto = data;
},
error => {
console.log('error: ', error);
});
So how is that even possible for it to behave differently? And why would that happen?