Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/holidaycheck/koa-check-origin
💣 A Koa middleware that throws a HTTP 403 when the given origin does not match.
https://github.com/holidaycheck/koa-check-origin
koa middleware origin
Last synced: 29 days ago
JSON representation
💣 A Koa middleware that throws a HTTP 403 when the given origin does not match.
- Host: GitHub
- URL: https://github.com/holidaycheck/koa-check-origin
- Owner: holidaycheck
- License: mit
- Created: 2018-10-24T11:56:59.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-12-08T22:16:20.000Z (about 2 months ago)
- Last Synced: 2024-12-08T23:20:19.576Z (about 2 months ago)
- Topics: koa, middleware, origin
- Language: TypeScript
- Homepage:
- Size: 135 KB
- Stars: 0
- Watchers: 7
- Forks: 0
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://img.shields.io/travis/holidaycheck/koa-check-origin/master.svg?style=flat)](https://travis-ci.org/holidaycheck/koa-check-origin)
[![NPM Downloads](https://img.shields.io/npm/dm/koa-check-origin.svg?style=flat)](https://www.npmjs.org/package/koa-check-origin)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat)](https://github.com/prettier/prettier)
[![Gitmoji](https://img.shields.io/badge/gitmoji-%20😜%20😍-FFDD67.svg?style=flat)](https://gitmoji.carloscuesta.me)
[![made-with-typescript](https://img.shields.io/badge/Made%20with-TypeScript-1f425f.svg?style=flat)](http://www.typescriptlang.org)# koa-check-origin
A [koa](https://koajs.com) middleware that checks if the origin matches the given base URL. If not a [HTTP 403](https://http.cat/403) is thrown.
## Installation 🏗
`koa-check-origin` requires `Node.js >= v7.6.0` because Koa [needs that](https://github.com/koajs/koa#installation) as well.
```sh
$ npm install --save koa-check-origin
```or if you use [Yarn](https://yarnpkg.com) 🐈
```sh
$ yarn add koa-check-origin
```## Usage 🔨
```js
const createCheckOriginMiddleware = require('koa-check-origin');const app = new Koa();
const checkOriginMiddleware = createCheckOriginMiddleware('http://example.com');
app.use(checkOriginMiddleware);
```