Dart proxy requests to backend server during development

Issue

Is there an equivalent of grunt-connect-proxy for Dart / pub ?

In production frontend stuff is built (pub build) as static resources and can be served by any web server (dart-agnostic).

During development I’d like to communicate with the backend server (non-Dart), without a need to build whole frontend with pub build and serve it with the backend server just to see some single change in frontend code.

This feature has already been proposed, but as of now it’s triaged: https://code.google.com/p/dart/issues/detail?id=16851.

It’s seems that this can only be done with pub, since communicating with backend, even within the same host, is done via CORS – at least that is what’s encouraged in the docs.

Solution

I’ve spend some time playing with the technology and found a solution that seems to work:
Just pub get and serve whole content(with subfolders!) of the web folder with your backend server. Then, open the page in dartium (use backend server socket address). No other servers should host the frontend code. The solution is IDE-agnostic.

Answered By – vucalur

Answer Checked By – Marie Seifert (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.