I'm upgrading an older app to .NET 6 and Angular 13. I've created a new Angular Net project from VS2022 then I've used it in upgrade. Now my app starts but seems that Angular sends api requests to a wrong port (44449 instead of 7148).
Where I can configure it? I found port configurations in:
project.cs
:
<SpaProxyServerUrl>https://localhost:7148</SpaProxyServerUrl>
Properties\launchSettings.json
:
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:33062",
"sslPort": 44349
}
ClientApp\launchSettings.json
:
"start:windows": "ng serve --port 44449 --ssl --ssl-cert %APPDATA%\\ASP.NET\\https\\%npm_package_name%.pem --ssl-key %APPDATA%\\ASP.NET\\https\\%npm_package_name%.key",
"start:default": "ng serve --port 44449 --ssl --ssl-cert $HOME/.aspnet/https/${npm_package_name}.pem --ssl-key $HOME/.aspnet/https/${npm_package_name}.key",
CodePudding user response:
You have two options :
1- update the launchSettings.json
to your desire port based on your request for HTTP or HTTPS
2- update the Angular to send request to current server port
I suggest the first one, it's easier and less error-prone the second option
If you need more help, just leave a comment!
CodePudding user response:
To have the Angular app call the port you want, change your ClientApp launch settings to:
"start:windows": "ng serve --port 7148 --ssl --ssl-cert %APPDATA%\\ASP.NET\\https\\%npm_package_name%.pem --ssl-key %APPDATA%\\ASP.NET\\https\\%npm_package_name%.key",
"start:default": "ng serve --port 7148 --ssl --ssl-cert $HOME/.aspnet/https/${npm_package_name}.pem --ssl-key $HOME/.aspnet/https/${npm_package_name}.key",