gpt4 book ai didi

javascript - Chrome 跨站点资源 - 网站无法正常工作

转载 作者:行者123 更新时间:2023-12-02 21:27:12 29 4
gpt4 key购买 nike

我有以下 HTML/ASPX 页面。

直到今天,它都运行得很好。

现在我遇到了跨站点错误,尽管对“阻止第三方 Cookie”或“添加站点以允许”进行了任何更改,但我仍无法像以前一样显示我的页面。

我使用的是 chrome 版本 80.0.3987.132,在该版本上一切正常,直到我清除所有浏览/缓存/cookie 历史记录。

JS 脚本将 Iframe 插入具有特定 ID 的 DIV 中。 我无法更改此行为,因为它是 API (Spotfire) 有没有办法解决此类示例中的跨站点资源问题?

https://server.com/处的跨站点资源关联的cookie设置时没有使用 SameSite 属性。它已被阻止,因为 Chrome 现在仅在设置了 SameSite=NoneSecure 的情况下才通过跨站点请求传递 cookie。您可以在开发者工具中的“应用程序”>“存储”>“Cookies”下查看 Cookie,并在 https://www.chromestatus.com/feature/5088147346030592 查看更多详细信息。和 https://www.chromestatus.com/feature/5633521622188032 .

<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta charset="utf-8">
<title>Spotfire Template</title>
<!--Spotfire Javascript API-->
<script type="text/javascript" src="https://server.com/spotfire/js-api/loader.js"></script>
<style>
/*Style the Divs that will hold the Spotfire Pages */
#Element1 {
padding: 0;
margin: 0 auto;
width: 100%;
height: 1090px;
}
#Element2 {
padding: 0;
margin: 0 auto;
width: 100%;
height: 1090px;
}
</style>
</head>
<body>
<!--Include Div Elements with IDs to hold the spotfire pages-->
<div id="Element1"></div>
<div id="Element2"></div>
<script>
//Specify Parameters
var app;
var doc;
var webPlayerServerRootUrl = "https://server.com/spotfire/wp/";
var analysisPath = "/Folder/Analysis";
var parameters = '';
var reloadInstances = false;
var apiVersion = "7.14";
var customizationInfo = {
showAbout: false,
showAnalysisInformationTool: false,
showAuthor: false,
showClose: false,
showCustomizableHeader: false,
showDodPanel: false,
showExportFile: false,
showExportVisualization: false,
showFilterPanel: false,
showHelp: false,
showLogout: false,
showPageNavigation: false,
showReloadAnalysis: false,
showStatusBar: false,
showToolBar: false,
showUndoRedo: false
};
//Declare more variables to add additonal Spotfire Pages
var view0;
var view1;
spotfire.webPlayer.createApplication(webPlayerServerRootUrl, customizationInfo, analysisPath, parameters, reloadInstances, apiVersion, onReadyCallback, onCreateLoginElement);
function onReadyCallback(response, newApp) {
app = newApp;
if (response.status === "OK") {
// The application is ready, meaning that the api is loaded and that the analysis path is validated for the current session (anonymous or logged in user)
console.log("OK received. Opening document to page 0 in element renderAnalysis")
//Add Items here for more pages , You can use Integers for Page Index or Title of Pages {First Element is the DIV ID and second is the PageName/PageIndex}
view0 = app.openDocument("Element1", 0);
view1 = app.openDocument("Element2", 1);
} else {
console.log("Status not OK. " + response.status + ": " + response.message)
}
}
function onError(error) {
console.log("Error: " + error);
}
function onCreateLoginElement() {
console.log("Creating the login element");
// Optionally create and return a div to host the login button
return null;
}
</script>
</body>
</html>

最佳答案

这看起来好像您希望在 server.com 的跨站点 iframe 中设置/发送 cookie。如果您控制 server.com,则可以配置其 cookie 以使用必要的 SameSite=None;保护属性。

有关 SameSite 和一般更改的更多信息如下:https://web.dev/samesite-cookies-explained

对于 Spotfire 配置,this page建议:

config export-config --force
config set-config-prop --name="security.cookies.same-site" --value="None"
config import-config -c "Cookies SameSite=None"

关于javascript - Chrome 跨站点资源 - 网站无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60710554/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com