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: about 1 year 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 7 years ago)
- Default Branch: master
- Last Pushed: 2025-02-12T22:39:14.000Z (over 1 year ago)
- Last Synced: 2025-03-27T13:45:35.281Z (about 1 year ago)
- Topics: koa, middleware, origin
- Language: TypeScript
- Homepage:
- Size: 136 KB
- Stars: 0
- Watchers: 6
- Forks: 0
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/holidaycheck/koa-check-origin)
[](https://www.npmjs.org/package/koa-check-origin)
[](https://github.com/prettier/prettier)
[](https://gitmoji.carloscuesta.me)
[](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);
```