WasmHeadersMiddleware class
Middleware that adds WebAssembly multi-threading headers to responses.
Adds the following headers required for SharedArrayBuffer and WASM multi-threading:
Cross-Origin-Opener-Policy: same-originCross-Origin-Embedder-Policy: require-corp
These headers enable Flutter web apps to use WebAssembly multi-threading features by establishing cross-origin isolation.
Usage with FlutterRoute
FlutterRoute automatically applies this middleware, so you typically don't need to use it directly:
pod.webServer.addRoute(FlutterRoute(Directory('web/app')));
Standalone Usage
You can also apply it manually to any route:
pod.webServer.addMiddleware(WasmHeadersMiddleware(), '/app');
How It Works
The middleware intercepts all Response objects and adds COOP/COEP headers. Other Result types (Hijack, WebSocketUpgrade) pass through unchanged. Existing headers are preserved.
- Inheritance
-
- Object
- MiddlewareObject
- WasmHeadersMiddleware
Constructors
- WasmHeadersMiddleware()
-
Creates a new WasmHeadersMiddleware
const
Properties
- asMiddleware → Middleware
-
Returns this MiddlewareObject as a Middleware function.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
call(
Handler next) → Handler -
The implementation of this MiddlewareObject
override
-
injectIn(
Router< Handler> router) → void -
Use this middleware on
routeron path/. Override to use on a different path.inherited -
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