I am working on a project for a company, everything is working fine when I use the server computer to test it, but when I try using the the employees computer to login, its not connecting.
Here's the am getting from chrome developer tools::: Access to XMLHttpRequest at 'http://localhost/smarthrapi/api/auth' from origin 'http://hrm' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
OPTIONS http://localhost/smarthrapi/api/auth 500 (Internal Server Error)
services.AddCors(o => o.AddPolicy("SmartHRCorsPolicy", builder =>
{
builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
}));
Cors is already enabled and this is the usage here
[EnableCors("SmartHRCorsPolicy")]
public class AuthController : Controller
{ mycode here
- If I use http://localhost/hrmanager/HR/login to log in on the server, its working fine, but when I try http://servername/hrmanager/HR/login on the employees computer, its not working. its as if its not seeing my Code or can't access the database.
- All the views are working fine, like when I try http://servername/hrmanager/HR/anotherpage the page is showing but nothing is working.
Is it that they're some restrictions on the server or is the problem from my code, I don't really know please help me. I wrote the code with MVC, I have APIs I called using ajax and am using sqlserver. Please the app need to be Live tomorrow, which means I need to fix it today. Thanks