Dart应用程序和跨域策略 [英] Dart application and cross domain policy
问题描述
在Dart VM中运行dart应用程序时,是否可以在Chromium中停用跨域安全检查?
Is it possible to disable cross domain security checks in Chromium while running dart application in Dart VM ?
问题是它在自己的端口上运行,因此我的应用程序无法向在另一个端口上运行的后端发送异步请求。
The problem is that it is running on its own port, and thus my application can't send asynchronous requests to my backend which is running on another port.
是的,我知道我可以将dart文件复制到我的后端,
Yes, I know that I can copy dart file to my backend and it will run just fine, but then I can't debug it.
推荐答案
如果你是一个停止间隙的解决方案,只是为了调试,您可以使用标记在chrome中关闭它。
If you're after a stop gap solution, just for debugging, you can use a flag to turn it off in chrome.
[chromium executable] --disable-web-security
这取自这篇文章 Chrome:禁用相同的原始政策。
否则,响应中的添加标题是正确的去。当然,如果您想提高安全性,您可以将星号替换为IP地址列表。
Otherwise, the addition header in the response is the right way to go. Of course, you can swap the asterisk for a list of IP addresses if you want to improve security.
请参阅 https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS 了解详情。
这篇关于Dart应用程序和跨域策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!