Angular Frontend with .NET Core API Backend: 500 Internal Server Error in Chrome (Works on...

Discussão em 'Angular' iniciado por parangat, Novembro 7, 2024.

  1. parangat

    parangat Guest

    I'm working on a project that uses Angular for the frontend and .NET Core Web API for the backend. The setup works perfectly in the localhost environment. However, after publishing, I encounter a 500 Internal Server Error in Chrome when calling an API. This issue doesn’t occur in Edge or Firefox.

    Additional details:

    1. I've set up CORS policies in .NET Core and allowed all origins.
    2. Clearing Chrome’s cache and history temporarily resolves the issue, but it reappears when the published link is opened again in Chrome.
    3. The problem only arises after deployment; locally, the API calls succeed without issues.

    What might cause this 500 error in Chrome after publishing, especially when the API calls work on localhost?

    Any insights on this issue would be highly appreciated.

    Update:

    var builder = WebApplication.CreateBuilder(args);
    builder.Services.AddCors(options =>
    {
    options.AddPolicy("CorsPolicy",
    builder => builder.AllowAnyOrigin()
    .AllowAnyMethod()
    .AllowAnyHeader());
    });

    var app = builder.Build();
    app.UseCors("CorsPolicy");


    This is how I have setup CORS policy

    Continue reading...

Compartilhe esta Página