So I've developed an asp .net core API that has to allow cross domain access. I've been able to get everything setup and running. I've enabled CORS and want it to apply the same setting across all of my endpoints so have the following in my Config method:
app.UseCors(builder => builder.WithOrigins(
"http://localhost:3000",
"http://localhost:3001",
"https://staging.example.com",
"https://production.server.com")
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials());
And in my ConfigureServices method:
services.AddCors();
The code is before the MVC middleware and when running locally I have to send requests from localhost:3000 as all others are rejected/blocked (as expected).
Also on staging and live the app works fine and can call the API without any issues.
However, when deployed to the staging or production I can call the API from my local machine using Postman as well as by pointing my local copy of the web app (an AngularJS app) to the API.
Maybe I'm missing something or my understanding is wrong but I thought this shouldn't be allowed! And if not then any thoughts about where I may be going wrong? It seems as though my API is allowing any request from any domain.