2

I have code that looks something like this (_http is the angular Http object)

    var httpFuture = _http.post('/api/items', {
      'ids': JSON.encode(new List.from(nonLoadedIds))
    });
    httpFuture.catchError((e) {
      Logger.root.severe('Unable to load items!', e);
    });

It is making a post request to load a bunch of things. Potentially more ids than the http get header can handle.

The nice development experience would be if I could fire up the dart editor, mock up some fake response data, run my app, and see the data in the end. I would also accept being able to start up a separate web app and somehow proxy my post requests to that web app.

What I don't want to do is change my '/api/items' into something like 'http://localhost:8084/api/items' mostly because I don't want to have to remember to replace these before deploying (I know I'll forget) and while doable, I don't want to on my server implement CORS just to have to remember to disable it when I deploy to production.

But really, I would accept just about any workflow if it is recommended. I just would like to eliminate any manual code transformations pre production deploy.

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
Cogman
  • 2,070
  • 19
  • 36
  • After poking around on the IRC channels, my current solution is to use a const debugging boolean and remembering to set it to 'false' before I do my build. Everywhere I need to hit the server, I'm doing this `const url = DEBUGGING ? '${HOST}/api/items' : '/api/items';` I'm not entirely satisfied by this solution, but it is there if someone else wants it. – Cogman Sep 01 '14 at 03:19

1 Answers1

1

The suggested attempt is to use a simple proxy server which forwards to pub serve.

See for example https://code.google.com/p/dart/issues/detail?id=18039 This issue contains the source code for a simple custom proxy server example https://code.google.com/p/dart/issues/detail?id=15731

see also

Community
  • 1
  • 1
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567