本文介绍了dart:调试dart客户端和现有rest api的客户端/服务器通信?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个休息api(开发在django / python),我运行本地,并希望开发一个简单的客户端应用程序在dart。此客户端使用XMLHttpRequest与本地django开发服务器通信。问题是Dart编辑器中的默认运行配置启动它自己的Web服务器,而不是dartium或具有dart2js的系统浏览器。



我想知道什么是最好的设置是测试客户端/服务器通信 - 应该我配置我的rest api代理:镖编辑器使用的3030端口,并配置带有URL的启动配置,或有一种方法告诉dart编辑器服务器发送访问控制允许原因http头(这将是真的很酷)或一些chrome启动参数禁用交叉原点检查XMLHttpRequests?



看起来像一个显然愚蠢的问题,找到(dart)文档中或中描述的任何解决方案 c>

$ <$>

解决方案请求 - 请参阅),你应该能够使用它,而不是 XMLHttpRequest



正在开发中,您还可以使用 - disable-web-security 选项启动Dartium (请参阅)


I have a rest api (developed in django/python) which i run locally and want to develop a simple client application in dart. This client uses XMLHttpRequest to communicate to a local django development server. The problem is the default run configuration in the Dart Editor launches it's own web server and than either dartium or the system browser with dart2js. Which will both obviously violate the cross origin policy when i try to access my rest api.

I'm wondering what the best setup would be to test client/server communication - should i configure my rest api to proxy the :3030 port which is used by the dart editor and configure a launch configuration with a URL, or is there a way to tell the dart editor server to send a "Access-Control-Allow-Origin" http header (this would be really cool), or some chrome launch parameter to disable cross origin checking for XMLHttpRequests?

seems like an obviously stupid problem, but i haven't found any solutions described in the (dart) documentation, or in previous questions here.

解决方案

Once Access-Control-Allow-Origin: * header has been added to every response of your REST API (don't forget OPTIONS request - see perlight request), you should be able to use it without problem with XMLHttpRequest and debug as it was on the same server.

Under development you can also use --disable-web-security option to launch Dartium ( see Chrome: Disable same origin policy )

这篇关于dart:调试dart客户端和现有rest api的客户端/服务器通信?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-26 04:10