【发布时间】:2021-09-08 09:04:36
【问题描述】:
我当前的 Nextjs 应用程序正在从 Cloudfront 提取其静态文件。 (我在部署过程中将 /static 文件夹上传到 S3)
自从更新到第 9 版后,我遇到了一个奇怪的问题,我的一些 CSS 文件出现以下 CORS 错误:
Access to fetch at 'https://xxx.cloudfront.net/assets/_next/static/css/b1a6e8370451b02b15e6.css' from origin 'https://example.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
将 Nextjs 更新到 10.1.4 版本后,该应用的所有链接都停止了工作。这与 CORS 问题有关,因为当我在没有 CDN 的情况下部署时一切正常。
S3 和 Cloudfront 均设置为接受 CORS 请求。
任何帮助将不胜感激。
【问题讨论】:
标签: javascript amazon-s3 caching cors next.js