Chrome仅在本地开发中出现跨域错误。如何解决? [英] Cross-domain error with Chrome in local dev only. How to resolve?
问题描述
我的本地计算机上出现了跨域错误(尽管代码在我们的Web服务器上完美运行)。这是发展的屁股真正的痛苦,所以我想知道的是 - 我可以在Chrome中调整设置以不再在本地获取该错误吗?
它是这样的:
不安全的JavaScript尝试访问带有URL文件的帧:///Users/david/login.html从带有URL文件的帧中获取:// /Users/david/varReturn.html。域名,协议和端口必须匹配。
谢谢!
I'm getting the cross-domain error on my local machine (although the code works perfectly on our web server). 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?
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. 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
. I encountered the same problem when reading text files from the same folder using JavaScript.
这篇关于Chrome仅在本地开发中出现跨域错误。如何解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!