我有一个ASP.NET API在本地运行,在MacBook Pro上,我可以用Swagger、Postman访问端点,在前端(运行在LiveServer上)使用Axios/JavaScript。
我已在iPhone上成功加载前端网页(192.168.0.10:5500/index.html),但Axios对端点的调用失败,并在控制台Failed to load resource: The certificate for this server is invalid. You might be connecting to a server that is pretending to be “192.168.0.10”, which could put your confidential information at risk.
中记录以下错误消息
运行命令dotnet dev-certs https --trust
会生成消息Successfully trusted the existing HTTPS certificate.
,但不能解决问题。
我错过什么了吗?
1条答案
按热度按时间mfuanj7w1#
@李莱克斯的评论奏效了。
app.UseHttpsRedirection();
。"applicationUrl": "https://localhost:7139;http://localhost:5171",
为API端点生成http和https url。编辑指向计算机/本地服务器IP的http路由,例如"applicationUrl": "https://localhost:7139;http://192.168.0.10:5171"