BloomCorsMiddleware class

Built-in Cross-Origin Resource Sharing (CORS) middleware for Bloom API endpoints.

Handles browser CORS preflight OPTIONS requests automatically with HTTP 204 No Content and injects appropriate Access-Control-* headers into all outgoing responses.

Example

// Default permissive CORS (all origins allowed)
router.use(BloomCorsMiddleware());

// Custom restricted CORS configuration
router.use(BloomCorsMiddleware(
  allowOrigin: 'https://app.example.com',
  allowMethods: 'GET, POST, PUT, DELETE',
  allowHeaders: 'Content-Type, Authorization, X-Workspace-ID',
  allowCredentials: true,
));
Implemented types

Constructors

BloomCorsMiddleware({String allowOrigin = '*', String allowMethods = 'GET, POST, PUT, DELETE, PATCH, OPTIONS', String allowHeaders = 'Content-Type, Authorization, X-Requested-With', bool allowCredentials = true})
Creates a BloomCorsMiddleware with customizable CORS headers.
const

Properties

allowCredentials bool
Whether credentials (cookies, HTTP authorization headers, TLS client certs) are permitted.
final
allowHeaders String
The Access-Control-Allow-Headers header value.
final
allowMethods String
The Access-Control-Allow-Methods header value.
final
allowOrigin String
The Access-Control-Allow-Origin header value (e.g. '*' or 'https://example.com').
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

handle(BloomRequest request, BloomNextFunction next) Future<BloomResponse?>
Processes the incoming request and optionally invokes next to continue the middleware pipeline.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited