platform/packages/proxy
2021-02-14 13:22:25 +08:00
..
.idea Add 'packages/proxy/' from commit 'daca263062d471ae007730fa8ecf854c09c746f8' 2020-02-15 18:22:25 -05:00
.vscode Add 'packages/proxy/' from commit 'daca263062d471ae007730fa8ecf854c09c746f8' 2020-02-15 18:22:25 -05:00
example Add 'packages/proxy/' from commit 'daca263062d471ae007730fa8ecf854c09c746f8' 2020-02-15 18:22:25 -05:00
lib Add 'packages/proxy/' from commit 'daca263062d471ae007730fa8ecf854c09c746f8' 2020-02-15 18:22:25 -05:00
test Add 'packages/proxy/' from commit 'daca263062d471ae007730fa8ecf854c09c746f8' 2020-02-15 18:22:25 -05:00
.gitignore Add 'packages/proxy/' from commit 'daca263062d471ae007730fa8ecf854c09c746f8' 2020-02-15 18:22:25 -05:00
.travis.yml Add 'packages/proxy/' from commit 'daca263062d471ae007730fa8ecf854c09c746f8' 2020-02-15 18:22:25 -05:00
analysis_options.yaml Add 'packages/proxy/' from commit 'daca263062d471ae007730fa8ecf854c09c746f8' 2020-02-15 18:22:25 -05:00
CHANGELOG.md Add 'packages/proxy/' from commit 'daca263062d471ae007730fa8ecf854c09c746f8' 2020-02-15 18:22:25 -05:00
LICENSE Add 'packages/proxy/' from commit 'daca263062d471ae007730fa8ecf854c09c746f8' 2020-02-15 18:22:25 -05:00
pubspec.yaml Updated dart requirements to 2.10 2021-02-14 13:22:25 +08:00
README.md Add 'packages/proxy/' from commit 'daca263062d471ae007730fa8ecf854c09c746f8' 2020-02-15 18:22:25 -05:00

proxy

Pub build status

Angel middleware to forward requests to another server (i.e. webdev serve). Also supports WebSockets.

import 'package:angel_proxy/angel_proxy.dart';
import 'package:http/http.dart' as http;

main() async {
  // Forward requests instead of serving statically.
  // You can also pass a URI, instead of a string.
  var proxy1 = Proxy('http://localhost:3000');
  
  // handle all methods (GET, POST, ...)
  app.fallback(proxy.handleRequest);
}

You can also restrict the proxy to serving only from a specific root:

Proxy(baseUrl, publicPath: '/remote');

Also, you can map requests to a root path on the remote server:

Proxy(baseUrl.replace(path: '/path'));

Request bodies will be forwarded as well, if they are not empty. This allows things like POST requests to function.

For a request body to be forwarded, the body must not have already been parsed.