ASP.NET core application and angular calling localhost instead of domain

Discussão em 'Angular' iniciado por GoodToGo, Junho 28, 2025.

  1. GoodToGo

    GoodToGo Guest

    I have a ASP.Net core application running on .NET 8 along with angular 18 in visual studio. The debug release works perfectly but when I deploy it to an external website, all API calls are going to localhost instead of domain root address.

    So instead of calling https://.net/api/account/login , it is calling https://localhost:7250/api/account/login.

    The environment.ts file in angular is set to

    export const environment = {
    production: true,
    baseUrl: "http://<myurl>.net/"
    };


    launchsettings.json is set to

    {
    "$schema": "http://json.schemastore.org/launchsettings.json",
    "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
    "applicationUrl": "http://localhost:46753",
    "sslPort": 44379
    }
    },
    "profiles": {
    "http": {
    "commandName": "Project",
    "dotnetRunMessages": true,
    "launchBrowser": true,
    "launchUrl": "swagger",
    "applicationUrl": "http://localhost:5191",
    "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Development",
    "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
    }
    },
    "https": {
    "commandName": "Project",
    "dotnetRunMessages": true,
    "launchBrowser": true,
    "launchUrl": "swagger",
    "applicationUrl": "http://<myurl>.net",
    "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Development",
    "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
    }
    },
    "IIS Express": {
    "commandName": "IISExpress",
    "launchBrowser": true,
    "launchUrl": "swagger",
    "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Development",
    "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
    }
    }
    }
    }


    What am I missing here?

    Continue reading...

Compartilhe esta Página