使用.NET Core API请求端口配置Angular
我正在将一个旧的应用升级到.NET 6和Angular 13。我创建了VS2022的新的Angular + Net项目,然后我在升级中使用了它。现在,我的应用开始,但似乎Angular将API请求发送到错误的端口(44449而不是7148)。
我可以在哪里配置它?我在以下位置找到了端口配置:
project.cs
:
<SpaProxyServerUrl>https://localhost:7148</SpaProxyServerUrl>
properties \ lastionsettings.json
:
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:33062",
"sslPort": 44349
}
client> client appapp \ laightsetsettings.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",
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",
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您有两个选项:
1-根据您对HTTP或HTTPS
2-更新Angular的请求,将请求发送到当前服务器端口,
我建议第一个,它是根据您的http 或https 2-更新 如果您需要更多帮助,请更容易且容易出错,这是第二个选项
,只需发表评论即可!
You have two options :
1- update the
launchSettings.json
to your desire port based on your request for HTTP or HTTPS2- 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!
要使Angular应用调用所需的端口,请将您的客户端应用启动设置更改为:
To have the Angular app call the port you want, change your ClientApp launch settings to: