繁体   English   中英

CORS 在没有 SSL 证书的 IIS 服务器中不起作用

[英]CORS not working in a IIS Server without SSL Certificate

I have a .net core API application but CORS doesnt work if its deployed in a IIS server that don't have an SSL Certification

除了在我们的服务器中注册 SSL 证书之外,还有其他解决方案吗?

注意:我们已经在后面的代码中指定允许所有来源/方法/凭据/标头

这与我的问题相同。

我已经在我的 Startup.cs 中添加了这些,但它不起作用。

        app.UseCors(builder => builder.WithOrigins("http://localhost:4200")
                .AllowAnyHeader()
                .AllowAnyMethod()
                .AllowCredentials());

  app.UseCors(builder => builder.AllowAnyOrigin()
                .AllowAnyHeader()
                .AllowAnyMethod()
                .AllowCredentials());

我什至添加了一个 OptionsMiddleware 但似乎不起作用。

我有同样的问题,但它解决了这个: -

<system.webServer>    
      <httpProtocol>
         <customHeaders>
             <add name="Access-Control-Allow-Origin" value="*" />
         </customHeaders>
       </httpProtocol>
      </system.webServer>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM