XmlHttpRequest cannot load due to access control, but access is configured?

41 views Asked by At

I am running locally a react app that i expose to the network with the the --host flag and a C# API, i added to the cors policy the ip address and port number that the app is exposed on. from my desktop all works fine, but when i attempt to access the site through my mobile phone thats connected to the same network the frontend loads correctly but when trying to make a POST request to login i get an error

XMLHttpRequest cannot load https://localhost:5000/someurl due to access control checks

and this error

POST https://localhost:5000/someurl Could not connect to the localhost:5000/someurl server.

here's my cors from the API

app.UseCors(policy => policy
    .WithOrigins("http://localhost:5173", "http://192.168.1.160:5173")
    .AllowAnyHeader()
    .AllowAnyMethod()
    .AllowCredentials());

Any suggestions what am i missing here?

NOTE: the order of the my middleware is UseCors, UseAuthentication, UseAuthorization

0

There are 0 answers