Skip to main content

cors_enabler 0.9.1+2 copy "cors_enabler: ^0.9.1+2" to clipboard
cors_enabler: ^0.9.1+2 copied to clipboard

A CORS proxy to make any API server CORS-compliant.

A tiny CORS proxy written in Dart.

The library provides a CorsProxy that listens for requests and forwards them to the remote URL provided when instantiating a proxy instance. The proxy will add permissive CORS headers so that browsers can access the proxied resources.

Usage #

  // start a local proxy forwarding to `targetUri`
  final proxy = CorsProxy(target: targetUri);
  await proxy.start();
  // the local proxy is listening on `boundPort`
  final boundPort = proxy.boundPort;

Example Usage #

Run from the project root:

dart run example/cors_enabler.dart https://api.target.com/ 8080

Then request:

http://localhost:8080/path/to/resource

Notes #

  • The proxy supports preflight OPTIONS requests and adds some CORS response headers such as Access-Control-Allow-Origin.
  • Be warned! It is designed for demonstration and development use; it does not implement advanced security checks or access restrictions.
1
likes
160
points
12
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A CORS proxy to make any API server CORS-compliant.

Repository (GitHub)
View/report issues

License

MIT (license)

More

Packages that depend on cors_enabler