Middleware to forward requests to another server (i.e. pub serve)
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea 1.1.0-alpha Sep 24, 2017
.vscode 1.0.8 Jun 20, 2017
example 2.1.0 Nov 9, 2018
lib 2.1.1 Dec 9, 2018
test 2.1.1 Dec 9, 2018
.gitignore ignore .dart_tool Mar 20, 2018
.travis.yml Works Nov 23, 2016
CHANGELOG.md 2.1.1 Dec 9, 2018
LICENSE Initial commit Nov 10, 2016
README.md 2.1.1 Dec 9, 2018
analysis_options.yaml 2.0.0 Nov 8, 2018
pubspec.yaml 2.1.1 Dec 9, 2018

README.md

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 {
  // ...
  
  var client = http.Client();
  
  // Forward requests instead of serving statically
  var proxy1 = Proxy(client, Uri.parse('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(client, baseUrl, publicPath: '/remote');

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

Proxy(client, 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.