Dart application and cross domain policy

我只是一个虾纸丫 提交于 2019-12-22 18:32:16

问题


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.

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.


回答1:


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

This is taken from this post Disable same origin policy in Chrome.

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.

See https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS for more details.




回答2:


Adding Access-Control-Allow-Origin: * to response headers on backend should be enough to make cross domain asynchronous requests.



来源:https://stackoverflow.com/questions/14021021/dart-application-and-cross-domain-policy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!