All Projects → zadzbw → Koa2 Cors

zadzbw / Koa2 Cors

Licence: other
CORS middleware for koa2

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Koa2 Cors

Workers
Cloudflare Workers
Stars: ✭ 111 (-50.22%)
Mutual labels:  cors
Rust Webapp Starter
Rust single page webapp written in actix-web with vuejs.
Stars: ✭ 151 (-32.29%)
Mutual labels:  cors
Aiohttp Cors
CORS support for aiohttp
Stars: ✭ 173 (-22.42%)
Mutual labels:  cors
Apiproject
[https://www.sofineday.com], golang项目开发脚手架,集成最佳实践(gin+gorm+go-redis+mongo+cors+jwt+json日志库zap(支持日志收集到kafka或mongo)+消息队列kafka+微信支付宝支付gopay+api加密+api反向代理+go modules依赖管理+headless爬虫chromedp+makefile+二进制压缩+livereload热加载)
Stars: ✭ 124 (-44.39%)
Mutual labels:  cors
Cors Vulnerable Lab
Sample vulnerable code and its exploit code
Stars: ✭ 149 (-33.18%)
Mutual labels:  cors
Cloudflare Cors Anywhere
CORS "anywhere" proxy in a Cloudflare worker. DEMO at: https://test.cors.workers.dev/
Stars: ✭ 162 (-27.35%)
Mutual labels:  cors
Typescript Restful Starter
Node.js + ExpressJS + Joi + Typeorm + Typescript + JWT + ES2015 + Clustering + Tslint + Mocha + Chai
Stars: ✭ 97 (-56.5%)
Mutual labels:  cors
Web Security Fundamentals
👨‍🏫 Mike's Web Security Course
Stars: ✭ 195 (-12.56%)
Mutual labels:  cors
Cors Container
A CORS proxy in a container (Docker) for when you need to `Access-Control-Allow-Origin: *`!
Stars: ✭ 150 (-32.74%)
Mutual labels:  cors
Routing Controllers Openapi
Runtime OpenAPI v3 schema generation for routing-controllers.
Stars: ✭ 170 (-23.77%)
Mutual labels:  koajs
Egg Cors
CORS plugin for egg
Stars: ✭ 140 (-37.22%)
Mutual labels:  cors
Browser Preview
🎢Preview html file in your default browser
Stars: ✭ 148 (-33.63%)
Mutual labels:  cors
Flusk
Boilerplate API on how to structure big Flask applications (includes SQLAlchemy, Docker, nginx)
Stars: ✭ 165 (-26.01%)
Mutual labels:  cors
Nelmiocorsbundle
The NelmioCorsBundle allows you to send Cross-Origin Resource Sharing headers with ACL-style per-URL configuration.
Stars: ✭ 1,615 (+624.22%)
Mutual labels:  cors
Xrcross
XRCross is a Reconstruction, Scanner, and a tool for penetration / BugBounty testing. This tool was built to test (XSS|SSRF|CORS|SSTI|IDOR|RCE|LFI|SQLI) vulnerabilities
Stars: ✭ 175 (-21.52%)
Mutual labels:  cors
Gin Cors
Cross Origin Resource Sharing middleware for gin-gonic
Stars: ✭ 107 (-52.02%)
Mutual labels:  cors
Create React Redux App Structure
Create React + Redux app structure with build configurations ✨
Stars: ✭ 161 (-27.8%)
Mutual labels:  cors
Express Es6 Rest Api
🔋 Starter project for an ES6 RESTful Express API.
Stars: ✭ 2,401 (+976.68%)
Mutual labels:  cors
Cool Admin Api
cool-admin-api 是基于egg.js、typeorm、jwt等封装的api开发脚手架、快速开发api接口
Stars: ✭ 188 (-15.7%)
Mutual labels:  koajs
React Redux Universal Boilerplate
An Universal ReactJS/Redux Boilerplate
Stars: ✭ 165 (-26.01%)
Mutual labels:  koajs

koa2-cors

NPM version Node version Build Status Code coverage NPM download Commitizen friendly

install

it requires node v7.6.0 or higher now

npm install --save koa2-cors

Usage

var Koa = require('koa');
var cors = require('koa2-cors');

var app = new Koa();
app.use(cors());

Options

origin

Configures the Access-Control-Allow-Origin CORS header. expects a string. Can also be set to a function, which takes the ctx as the first parameter.

exposeHeaders

Configures the Access-Control-Expose-Headers CORS header. Expects a comma-delimited array.

maxAge

Configures the Access-Control-Max-Age CORS header. Expects a Number.

credentials

Configures the Access-Control-Allow-Credentials CORS header. Expects a Boolean.

allowMethods

Configures the Access-Control-Allow-Methods CORS header. Expects a comma-delimited array , If not specified, default allowMethods is ['GET', 'PUT', 'POST', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS'].

allowHeaders

Configures the Access-Control-Allow-Headers CORS header. Expects a comma-delimited array . If not specified, defaults to reflecting the headers specified in the request's Access-Control-Request-Headers header.

var Koa = require('koa');
var cors = require('koa2-cors');

var app = new Koa();
app.use(cors({
  origin: function(ctx) {
    if (ctx.url === '/test') {
      return false;
    }
    return '*';
  },
  exposeHeaders: ['WWW-Authenticate', 'Server-Authorization'],
  maxAge: 5,
  credentials: true,
  allowMethods: ['GET', 'POST', 'DELETE'],
  allowHeaders: ['Content-Type', 'Authorization', 'Accept'],
}));
...

More details about CORS.

License

MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].