Chrome仅在本地开发中出现跨域错误。如何解决? [英] Cross-domain error with Chrome in local dev only. How to resolve?

查看:308
本文介绍了Chrome仅在本地开发中出现跨域错误。如何解决?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的本​​地计算机上出现了跨域错误(尽管代码在我们的Web服务器上完美运行)。这是发展的屁股真正的痛苦,所以我想知道的是 - 我可以在Chrome中调整设置以不再在本地获取该错误吗?



它是这样的:

不安全的JavaScript尝试访问带有URL文件的帧:///Users/david/login.html从带有URL文件的帧中获取:// /Users/david/varReturn.html。域名,协议和端口必须匹配。



谢谢!

解决方案 - 允许文件访问从文件运行chrome。使用JavaScript从同一文件夹读取文本文件时遇到同样的问题。


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屋!

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