Giter Site home page Giter Site logo

httpland / corp-middleware Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 12 KB

HTTP cross-origin resource policy(CORP) middleware

Home Page: https://deno.land/x/corp_middleware

License: MIT License

TypeScript 100.00%
corp cross-origin fetch-api header http middleware same-origin security cross-origin-resource-policy same-site

corp-middleware's Introduction

corp-middleware

deno land deno doc GitHub release (latest by date) codecov GitHub

test NPM

HTTP cross-origin resource policy(CORP) middleware.

Compliant with Fetch, 3.6. Cross-Origin-Resource-Policy header.

Middleware

For a definition of Universal HTTP middleware, see the http-middleware project.

Usage

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.

Policy

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

Conditions

Middleware will execute if all of the following conditions are met:

  • Response does not include Cross-Origin-Resource-Policy header

Effects

Middleware may make changes to the following elements of the HTTP message.

  • HTTP Headers
    • Cross-Origin-Resource-Policy

API

All APIs can be found in the deno doc.

License

Copyright © 2023-present httpland.

Released under the MIT license

corp-middleware's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.