How to debug client-side dart code in the Dart editor without CORS

I have a server / client project, both written in a dart. Now my server starts at port 1337 , and when I start my client with Run in dartium , my static files are served on port 3030 , which allows me to debug the client code in the Dart editor.

The problem is that when using AJAX <this calls CORS ./a>. I correctly configured my server to accept other sources (with Access-Control-Allow-Origin ), but, for example, cookies are not sent together.

Now I'm wondering: is there a way to serve my files with my server (runs on 1337 ) and is there still the ability to debug client-side code in the dart editor?

+1
cors dart dartium dart-editor
Jun 05 '13 at 11:56 on
source share
1 answer

I understand that you can debug, but the real problem is that you are not getting the expected data from the server due to the lack of cookies.

Standard CORS requests do not send or set cookies by default.

To enable cookies as part of the request, in addition to configuring the server, you need to specify the withCredentials property, for example:

 HttpRequest.getString(url, withCredentials:true)... 

You will also need to configure the server to provide the Access-Control-Allow-Credentials header.

EDIT: It seems like an additional problem is that you do not want to have 2 servers, each of which serves a separate part of the application.

In this case, you can configure DartEditor to run the URL instead of files. Go to Run > Manage Launches and add a new Dartium or Dart2JS launch with the specified URL and source directory.

Another option is to select Run > Remote Connection and connect to a running instance of the browser or Dart VM.

Caution: I have not tried these parameters, so I can’t say how stable they are .

+4
Jun 05 '13 at 14:56
source share



All Articles