如何修复 Cloudfront CDN 中的 CORS 问题?

如何修复 Cloudfront CDN 中的 CORS 问题?

我运营一个 WordPress 网站,最近使用 CloudFront 配置了一个 CDN。

大多数功能都运行良好,但我从 Github 加载 JS 文件时遇到了 CORS 问题。

我尝试了很多方法来解决此问题,但仍然出现以下错误。

Ensure CORS response header values are valid

A cross-origin resource sharing (CORS) request was blocked because of invalid or missing response headers of the request or the associated preflight request .

To fix this issue, ensure the response to the CORS request and/or the associated preflight request are not missing headers and use valid header values.

Note that if an opaque response is sufficient, the request's mode can be set to no-cors to fetch the resource with CORS disabled; that way CORS headers are not required but the response content is inaccessible (opaque).

这是我在 Cloudfront 上的设置 ->https://imgsh.net/a/5GFcr4m.jpg


Access-Control-Allow-Credentials
false
Access-Control-Allow-Headers
Access-Control-Allow-Methods
GET
HEAD
PUT
POST
PATCH
DELETE
OPTIONS
Access-Control-Allow-Origin
*
Access-Control-Expose-Headers
*
Access-Control-Max-Age (seconds)

有人可以告诉我如何解决这个问题吗?

相关内容