HTTP cross-origin resource policy(CORP) middleware.
Compliant with
Fetch, 3.6. Cross-Origin-Resource-Policy
header.
For a definition of Universal HTTP middleware, see the http-middleware project.
Middleware adds the Cross-Origin-Resource-Policy
header to the response.
import {
corp,
type Handler,
} from "https://deno.land/x/corp_middleware@$VERSION/mod.ts";
import { assert } from "https://deno.land/std/testing/asserts.ts";
declare const request: Request;
declare const handler: Handler;
const middleware = corp();
const response = await middleware(request, handler);
assert(response.headers.has("cross-origin-resource-policy"));
yield:
Cross-Origin-Resource-Policy: same-origin
The default field value is same-origin
.
To change the corp policy, do the following:
import {
corp,
} from "https://deno.land/x/corp_middleware@$VERSION/middleware.ts";
const middleware = corp("cross-origin");
yield:
Cross-Origin-Resource-Policy: cross-origin
Middleware will execute if all of the following conditions are met:
- Response does not include
Cross-Origin-Resource-Policy
header
Middleware may make changes to the following elements of the HTTP message.
- HTTP Headers
- Cross-Origin-Resource-Policy
All APIs can be found in the deno doc.
Copyright © 2023-present httpland.
Released under the MIT license