shelf_cors 0.2.1 copy "shelf_cors: ^0.2.1" to clipboard
shelf_cors: ^0.2.1 copied to clipboard

Dart 1 only

Middleware to add CORS headers to shelf responses.

Add CORS Headers Middleware #

A Shelf middleware to add CORS headers to shelf responses. Also handles preflight requests.

Usage #

A simple usage example:

import 'package:shelf/shelf.dart' as shelf;
import 'package:shelf/shelf_io.dart' as shelf_io;
import 'package:shelf_cors/shelf_cors.dart' as shelf_cors;

shelf.Response handleAll(shelf.Request request) {
  return new shelf.Response.ok("OK");
}

var handler = const shelf.Pipeline()
    .addMiddleware(shelf_cors.createCorsHeadersMiddleware())
    .addHandler(handleAll);

shelf_io.serve(handler, InternetAddress.ANY_IP_V4, port).then((server) {
  print("Serving at http://${server.address.host}:${server.port}");
});
copied to clipboard

Features and bugs #

Please file feature requests and bugs at the issue tracker.

0
likes
25
points
33
downloads

Publisher

unverified uploader

Weekly Downloads

2024.09.22 - 2025.04.06

Middleware to add CORS headers to shelf responses.

Repository (GitHub)

License

BSD-3-Clause (license)

Dependencies

shelf

More

Packages that depend on shelf_cors