IIS 配置静态网站跨域
IIS 配置静态网站跨域
打开项目目录 文件所在位置
编辑 web.config
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <directoryBrowse enabled="true" /> <httpProtocol> <customHeaders> <add name="Access-Control-Allow-Origin" value="*" /> <add name="Access-Control-Allow-Headers" value="Content-Type" /> <add name="Access-Control-Allow-Methods" value="GET" /> </customHeaders> </httpProtocol> <staticContent> <remove fileExtension=".glb" /> <mimeMap fileExtension=".b3dm" mimeType="application/octet-stream" /> <mimeMap fileExtension=".gltf" mimeType="model/gltf+json" /> <mimeMap fileExtension=".glb" mimeType="model/gltf-binary" /> <mimeMap fileExtension=".cmpts" mimeType="application/octet-stream" /> </staticContent> </system.webServer> </configuration>
参考:
<httpProtocol> <customHeaders> <add name="Access-Control-Allow-Methods" value="OPTIONS,POST,GET"/> <add name="Access-Control-Allow-Headers" value="x-requested-with,Content-Type"/> <add name="Access-Control-Allow-Origin" value="*" /> </customHeaders> </httpProtocol>
重启IIS即可