Pregunta

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.

¿Fue útil?

Solución

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 Disable same origin policy in Chrome )

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top