这个问题在这里已有答案:

我正在使用Docker运行前端Angular应用程序,dotnet核心API和IdentityServer4身份验证服务器 . Angular应用程序在 localhost:5004 上运行,API在 localhost:5335 上运行 . 两个应用程序都可以通过Docker正常工作,但是当我尝试从Angular应用程序调用 http://localhost:5335/api/this/ 时,我不断收到以下错误:

从'http:// localhost:5004'访问来自'http:// localhost:5335 /api/users/exists/Bob@ooo.com'的XMLHttpRequest已被CORS策略阻止:否'访问控制 - Allow-Origin'标头出现在请求的资源上 .

Chrome网络标签下的我的API请求如下所示:

Request URL: http://localhost:5335/api/users/exists/Bob@exp.com
Request Method: GET
Status Code: 500 Internal Server Error
Remote Address: [::1]:5335
Referrer Policy: no-referrer-when-downgrade

关于可能出现什么问题的任何建议? API调用在本地工作正常 . 任何形式的帮助将不胜感激