angel_proxy 1.1.1

  • Example
  • Installing
  • Versions
  • 72


Pub build status

Angel middleware to forward requests to another server (i.e. pub serve).

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

main() async {
  // ...
  var client = new http.Client();
  var proxy = new Proxy(app, client, 'http://localhost:3000');
  // Forward requests instead of serving statically

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

new Proxy(app, client, '<host>', publicPath: '/remote');

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

new Proxy(app, client, '<host>', mapTo: '/path');

If your app's storeOriginalBuffer is true, then request bodies will be forwarded as well, if they are not empty. This allows things like POST requests to function.


Removed reference to io; now works with HTTP/2. Thanks to @daniel-v!


import 'dart:io';
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_proxy/angel_proxy.dart';
import 'package:http/http.dart' as http;
import 'package:logging/logging.dart';

final Duration timeout = new Duration(seconds: 5);

main() async {
  var app = new Angel();
  var client = new http.Client();

  // Forward any /api requests to pub.
  // By default, if the host throws a 404, the request will fall through to the next handler.
  var pubProxy = new Proxy(
    publicPath: '/pub',
    timeout: timeout,

  // Pub's HTML assumes that the site's styles, etc. are on the absolute path `/static`.
  // This is not the case here. Let's patch that up:
  app.get('/static/*', (RequestContext req, res) {
    return pubProxy.servePath(req.path, req, res);

  // Anything else should fall through to
  var dartlangProxy = new Proxy(
    timeout: timeout,
    recoverFrom404: false,

  // In case we can't connect to, show an error.
  app.use('Couldn\'t connect to Pub or dartlang.');

  app.logger = new Logger('angel')
      (rec) {
        if (rec.error != null) print(rec.error);
        if (rec.stackTrace != null) print(rec.stackTrace);

  var server = await app.startServer(InternetAddress.LOOPBACK_IP_V4, 8080);
  print('Listening at http://${server.address.address}:${server.port}');
  print('Check this out! http://${server.address.address}:${server.port}/pub/packages/angel_framework');

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  angel_proxy: ^1.1.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:angel_proxy/angel_proxy.dart';
Version Uploaded Documentation Archive
1.1.1 Mar 20, 2018 Go to the documentation of angel_proxy 1.1.1 Download angel_proxy 1.1.1 archive
1.1.0 Dec 7, 2017 Go to the documentation of angel_proxy 1.1.0 Download angel_proxy 1.1.0 archive
1.0.9 Jul 24, 2017 Go to the documentation of angel_proxy 1.0.9 Download angel_proxy 1.0.9 archive
1.0.8 Jun 20, 2017 Go to the documentation of angel_proxy 1.0.8 Download angel_proxy 1.0.8 archive
1.0.7 Apr 26, 2017 Go to the documentation of angel_proxy 1.0.7 Download angel_proxy 1.0.7 archive
1.0.6 Apr 24, 2017 Go to the documentation of angel_proxy 1.0.6 Download angel_proxy 1.0.6 archive
1.0.5+1 Apr 22, 2017 Go to the documentation of angel_proxy 1.0.5+1 Download angel_proxy 1.0.5+1 archive
1.0.5 Apr 22, 2017 Go to the documentation of angel_proxy 1.0.5 Download angel_proxy 1.0.5 archive
1.0.4 Apr 22, 2017 Go to the documentation of angel_proxy 1.0.4 Download angel_proxy 1.0.4 archive
1.0.3 Apr 22, 2017 Go to the documentation of angel_proxy 1.0.3 Download angel_proxy 1.0.3 archive

All 21 versions...

Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Aug 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status tool failures using:

  • Dart: 2.0.0
  • pana: 0.11.8


Detected platforms: unsure

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Issues and suggestions

Fix dependencies in pubspec.yaml.

Running pub upgrade failed with the following output:

ERR: The current Dart SDK version is 2.0.0.
 Because angel_framework >=0.0.0-dev.1 <1.1.3 requires SDK version <2.0.0 and angel_framework >=1.1.3 depends on random_string ^0.0.1, angel_framework >=0.0.0-dev.1 requires random_string ^0.0.1.
 So, because every version of random_string requires SDK version >=1.0.0 <2.0.0 and angel_proxy depends on angel_framework ^1.1.0-alpha, version solving failed.

Fix platform conflicts.

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <3.0.0