javascript - 获取 Cors 策略错误本地主机无法运行
问题描述
我在运行本地主机时收到此消息,因为我在 Net SuiteCommerce 高级电子商务网上商店工作,但从最近两天开始,我收到此错误。我在 Stackoverflow 和其他一些网站上搜索过它,但没有得到任何令人满意的解决方案,所以我将它发布在这里。
尝试下载 Cors 扩展并激活,但它不起作用。除了谷歌浏览器之外,本地主机运行良好。
define(
'JJRename.Rename.Rename'
, [
'Utils',
'MenuTree.View',
'Header.Menu.MyAccount.View',
'JJRename.Rename.Rename.View'
]
, function (
Utils,
MenuTreeView,
HeaderMenuMyAccountView,
RenameView
)
{
'use strict';
return {
mountToApp: function mountToApp (container)
{
var layout = container.getComponent('Layout');
_.extend(MenuTreeView.prototype,{
getContext: _.wrap(MenuTreeView.prototype.getContext, function (fn){
var changeName = fn.apply(this, _.toArray(arguments).slice(1));
var array = changeName.menuItems;
_.each(changeName.menuItems, function (second){
_.each(second.children, function (children){
if(children.name == "Email Preferences"){
children.name = "Subscriptions"
}
});
});
return changeName;
})
});
_.extend(HeaderMenuMyAccountView.prototype, {
getContext: _.wrap(HeaderMenuMyAccountView.prototype.getContext, function (fn){
var helloWorld = fn.apply(this, _.toArray(arguments).slice(1));
console.log("first", helloWorld)
_.each(helloWorld.entries, function (first){
_.each(first.children, function (children){
if(children.name == "Email Preferences"){
children.name = "Subscriptions"
}
});
});
return helloWorld;
})
});
}
};
});
Access to XMLHttpRequest at 'http://localhost:7777/who/shopping' from origin 'http://www.cricketsca.ml' has been blocked by CORS policy:
请求客户端不是安全上下文,资源位于更私密的地址空间local
中。
shopping-local.ssp:1 从源“http://www.cricketsca.ml”访问“http://localhost:7777/extensions/J_J/JJ_Base_Theme/3.0.2/img/favicon.ico”的资源有被 CORS 策略阻止:请求客户端不是安全上下文,资源位于更私密的地址空间local
中。
解决方案
这可能是因为最近的 Google Chrome 更新。之前也有过类似的问题,但有一些变通办法。现在您可以尝试其他浏览器(例如 Firefox)。
推荐阅读
- javascript - 比较两个数组并合并不重复
- bootstrap-4 - Angular 中的 Boostrap 4 Navbar Dropdown 不适用于小型设备
- python - 如何将新列作为字符串分配给 Pandas Assign
- flutter - 类型“int”是否不是“double”类型的子类型
- mysql - 如何使用另一个表中的值更新特定列
- javascript - 当模型和模式存储在另一个文件中时,如何使用 findOne() 或 find() 等方法从 Node js 中的 MongoDB 检索文档?
- java - OjAlgo 特征值是否总是按降序排列?
- java - 我应该使用 2 路聚合还是有更好的解决方案?
- c++ - 如何并行执行 BIG RGB 图像的 jpeg 编码?
- sql - AnyLogic:由速率和匹配变量定义的到达