如何在Windows 10的IIS管理器上启用CORS? [英] How to enable CORS on IIS Manager of Windows 10?
问题描述
我已经使用IIS管理器(Windows 10)创建了HTTPS服务器。现在,我希望该服务器支持CORS请求。
I've created an HTTPS server using IIS Manager (Windows 10). Now, I want this server to support CORS requests.
我已经阅读了一些信息。例如,
此链接表示我必须在以下位置创建文件web.config目录。不幸的是,它没有成功。
此链接表示我应该编辑一些配置文件,但是在我的机器上找不到它们。
I've read some information. For example, this link says that I have to create a file web.config in the directory. Unfortunately, it didn't work out. This link says that I should edit some config files, but I don't find them on my machine.
推荐答案
最近我遇到了类似的问题。大多数教程/文档仅建议在配置中添加自定义标头。但这并不能告诉IIS自行处理CORS飞行前请求。
I had a similar issue recently. Most tutorial/documentation only suggests adding custom headers in the configuration. But this does not tell IIS to handle the CORS Pre-flight request by itself.
为此,您必须安装 CORS模块,并在web.config文件中添加一些配置,如下所述: IIS CORS模块配置参考
To do so, you must install the CORS Module in IIS and add some configuration in the web.config file, as explained here: IIS CORS module Configuration Reference
我最近使用它来反向代理到REST API并仅在IIS中处理CORS,这样我就不必重建项目来更改CORS设置。
I recently used this to Reverse Proxy to a REST API and handling the CORS only in IIS so that I don't have to rebuild my project to change CORS settings.
这篇关于如何在Windows 10的IIS管理器上启用CORS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!