platform/packages/proxy
2024-07-07 23:02:49 +08:00
..
example Published proxy and file_service 2021-06-10 16:47:05 +08:00
lib Fixed deprecated warnings 2022-09-19 22:28:39 +08:00
test Fixed production analyze warnings 2022-08-27 17:23:41 +08:00
.gitignore Add 'packages/proxy/' from commit 'daca263062d471ae007730fa8ecf854c09c746f8' 2020-02-15 18:22:25 -05:00
analysis_options.yaml Updated linter 2022-01-04 20:03:52 +08:00
AUTHORS.md Published proxy and file_service 2021-06-10 16:47:05 +08:00
CHANGELOG.md Updated to support SDK 3.3.0 2024-06-23 12:09:26 +08:00
LICENSE Updated linter 2022-01-04 20:03:52 +08:00
melos_angel3_proxy.iml Added melos 2022-03-19 09:37:28 +08:00
pubspec.yaml Updated to support SDK 3.3.0 2024-06-23 12:09:26 +08:00
README.md Replaced Gitter with Discord chat 2024-07-07 23:02:49 +08:00

Angel3 Proxy

Pub Version (including pre-releases) Null Safety Discord License

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

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

void 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.