All Projects → eggjs → Egg Cors

eggjs / Egg Cors

Licence: mit
CORS plugin for egg

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Egg Cors

Egg Sofa Rpc
SOFARPC plugin for egg
Stars: ✭ 71 (-49.29%)
Mutual labels:  egg-plugin
Ecommerce Nodejs
Ecommerce application back-end codes
Stars: ✭ 97 (-30.71%)
Mutual labels:  cors
Egg Router Plus
The missing router feature for eggjs
Stars: ✭ 117 (-16.43%)
Mutual labels:  egg-plugin
Rocket cors
Cross-origin resource sharing (CORS) for Rocket.rs applications
Stars: ✭ 73 (-47.86%)
Mutual labels:  cors
Cors Now
reverse proxy with CORS headers.
Stars: ✭ 93 (-33.57%)
Mutual labels:  cors
Egg Passport
passport plugin for egg
Stars: ✭ 98 (-30%)
Mutual labels:  egg-plugin
Laravel Api Boilerplate Jwt
A Laravel 5.8 API Boilerplate to create a ready-to-use REST API in seconds.
Stars: ✭ 1,155 (+725%)
Mutual labels:  cors
Skyapm Nodejs
The NodeJS server side agent for Apache SkyWalking
Stars: ✭ 124 (-11.43%)
Mutual labels:  egg-plugin
Nodefony Starter
Nodefony Starter Node.js Framework
Stars: ✭ 95 (-32.14%)
Mutual labels:  cors
Nelmiocorsbundle
The NelmioCorsBundle allows you to send Cross-Origin Resource Sharing headers with ACL-style per-URL configuration.
Stars: ✭ 1,615 (+1053.57%)
Mutual labels:  cors
Egg Schedule
Schedule plugin for egg
Stars: ✭ 76 (-45.71%)
Mutual labels:  egg-plugin
Corser
CORS middleware for Node.js
Stars: ✭ 90 (-35.71%)
Mutual labels:  cors
Gin Cors
Cross Origin Resource Sharing middleware for gin-gonic
Stars: ✭ 107 (-23.57%)
Mutual labels:  cors
Public Cakephp Rest Api
CakePHP 3 plugin for building REST API services
Stars: ✭ 71 (-49.29%)
Mutual labels:  cors
Egg Mongodb Example
a example of eggjs, mongodb, restful api and other stuff made it work...
Stars: ✭ 123 (-12.14%)
Mutual labels:  egg-plugin
Egg Mongo Native
MongoDB egg.js plugin using native driver.
Stars: ✭ 69 (-50.71%)
Mutual labels:  egg-plugin
Typescript Restful Starter
Node.js + ExpressJS + Joi + Typeorm + Typescript + JWT + ES2015 + Clustering + Tslint + Mocha + Chai
Stars: ✭ 97 (-30.71%)
Mutual labels:  cors
Egg View Vue
vue view plugin for egg
Stars: ✭ 136 (-2.86%)
Mutual labels:  egg-plugin
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 (-11.43%)
Mutual labels:  cors
Workers
Cloudflare Workers
Stars: ✭ 111 (-20.71%)
Mutual labels:  cors

egg-cors

NPM version build status Test coverage David deps Known Vulnerabilities npm download

CORS plugin for egg, based on @koa/cors.

Install

$ npm i egg-cors --save

Usage

// {app_root}/config/plugin.js
exports.cors = {
  enable: true,
  package: 'egg-cors',
};

egg-cors works internally with egg-security. By defining the property of domainWhiteList on object security, you have successfully informed the framework to whitelist the passed domains.

When you make a request from client side, egg should return an Access-Control-Allow-Origin response header with the domain that you passed in along with the payload and status code 200.

exports.security = {
  domainWhiteList: [ 'http://localhost:4200' ],
};

Configuration

Support all configurations in @koa/cors.

// {app_root}/config/config.default.js
exports.cors = {
  // {string|Function} origin: '*',
  // {string|Array} allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH'
};

If the origin is set, the plugin will follow it to set the Access-Control-Allow-Origin and ignore the security.domainWhiteList. Otherwise, the security.domainWhiteList which is default will take effect as described above.

Security

Only in safe domain list support CORS when security plugin enabled.

Questions & Suggestions

Please open an issue here.

License

MIT

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].