我在使用 CORS 和網頁時遇到問題:在頁面加載之前更改網頁值但沒有發(fā)生在任何其他頁面上我無法使用 jQuery 正確加載主頁但具有相同腳本的所有其他頁面加載正常不適用于 Chrome但適用于本地和 Firefox更改了 S3 CORS 配置權限,但尚未解決問題AWS S3 存儲桶 > 權限 > CORS 配置<!DOCTYPE html><html> <head> <script type="text/javascript" crossorigin="anonymous">$(function () { $.get("assets/head.html", function (data) { $("head").prepend(data); }); });</script> </head> <body class="container"> </body></html>變成:<!DOCTYPE html><html> <head> <script type="text/javascript" crossorigin="anonymous">$(function () { $.get("https://s3-example.amazonaws.com/aws-codestar-example/public/assets/head.html", function (data) { $("head").prepend(data); }); });</script> </head> <body class="container"> </body></html>錯誤是:Access to XMLHttpRequest at 'https://s3-example.amazonaws.com/aws-codestar-example/public/assets/head.html' from origin 'http://example2.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.為什么源在 Chrome 讀取之前會發(fā)生變化?
運行時替換的 Index.html 腳本標記值
MMTTMM
2021-11-18 20:44:30