Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dart proxy requests to backend server during development

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.

like image 793
vucalur Avatar asked Oct 31 '22 22:10

vucalur


1 Answers

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.

like image 196
vucalur Avatar answered Nov 15 '22 07:11

vucalur