试图禁用Chrome同源策略 [英] Trying to disable Chrome same origin policy

查看:469
本文介绍了试图禁用Chrome同源策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图按照melonJS教程。它说我应该使用以下两种方法之一禁用交叉源请求:



- disable-web-security



- 允许文件从文件访问**



我在我的命令提示符中尝试了这两种方法:

  C:\ Users \danniu> C: \ Users \danniu\AppData\Local\Google\Chrome\Application\Chrome.e 
xe - 允许文件从文件访问

C:\ Users \danniu> C:\ Users \danniu\AppData\Local\Google\Chrome\Application\Chrome.e
xe --disable-web-security

当我尝试在Chrome中运行游戏时,仍然收到此错误:



XMLHttpRequest无法加载file:/// C:/Users/danniu/Desktop/JavaScript/melonJS/data/map/area01.tmx。只有HTTP支持跨源请求。



我做错了什么?



感谢

解决方案

您需要使用两个参数。这是我如何在我的Mac上运行它。

  open -a Google\ Chrome --args --disable-web-安全 - 允许文件从文件中访问

这对于Windows应该是这样的:

 C:\ PathTo\Chrome.exe-allow-file-access-from-files -disable-web - 安全


I'm trying to follow a melonJS tutorial. It says I should disable cross-origin request using one of two methods:

--disable-web-security

--allow-file-access-from-files**

I've tried both of these in my command prompt as such:

C:\Users\danniu>C:\Users\danniu\AppData\Local\Google\Chrome\Application\Chrome.e
xe --allow-file-access-from-files

C:\Users\danniu>C:\Users\danniu\AppData\Local\Google\Chrome\Application\Chrome.e
xe --disable-web-security

When I try to run the game in Chrome I'm still getting this error:

XMLHttpRequest cannot load file:///C:/Users/danniu/Desktop/JavaScript/melonJS/data/map/area01.tmx. Cross origin requests are only supported for HTTP.

What am I doing wrong?

Thanks

解决方案

You need to use both arguments. This is how I run it on my mac.

open -a Google\ Chrome --args --disable-web-security -–allow-file-access-from-files

This is how it should be for windows:

"C:\PathTo\Chrome.exe" –allow-file-access-from-files -disable-web-security

这篇关于试图禁用Chrome同源策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆