简体   繁体   English

Chrome仅在本地开发中出现跨域错误。 怎么解决?

[英]Cross-domain error with Chrome in local dev only. How to resolve?

I'm getting the cross-domain error on my local machine (although the code works perfectly on our web server). 我在本地计算机上遇到跨域错误(尽管代码在我们的Web服务器上运行良好)。 This is a real pain in the butt for development, so what I'm wondering is this - can I adjust a setting in Chrome to not get that error locally anymore? 这对于开发来说是一个真正的痛苦,所以我想知道的是 - 我可以调整Chrome中的设置以便不再在本地获得该错误吗?

It's this one: 就是这个:

Unsafe JavaScript attempt to access frame with URL file:///Users/david/login.html from frame with URL file:///Users/david/varReturn.html. 不安全的JavaScript尝试使用URL文件访问框架:///Users/david/login.html来自URL文件:///Users/david/varReturn.html。 Domains, protocols and ports must match. 域,协议和端口必须匹配。

Thanks! 谢谢!

Google has decided that offline file access is cross-domain, regardless. 谷歌已经决定离线文件访问是跨域的,无论如何。 You can try running chrome with --allow-file-access-from-files . 您可以尝试使用--allow-file-access-from-files运行chrome。 I encountered the same problem when reading text files from the same folder using JavaScript. 使用JavaScript从同一文件夹中读取文本文件时遇到了同样的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM