Skip to content

Latest commit

 

History

History
26 lines (19 loc) · 527 Bytes

File metadata and controls

26 lines (19 loc) · 527 Bytes

koa CORS middleware in bpframework.

Middleware specification

https://github.com/bpcloud/middleware

usage

Setup.

import { Application } from 'bpframework';
import * as middleware_cors from '@bpframework/middleware-koa-cors';

// set CORS by default.
Application.use(middleware_cors.middleware({
  allowOrigin: '*',
  withCredentials: true,
  allowHeaders: ['X-Custom-Headers'],
  exposeHeaders: ['X-Custom-Headers'],
}));
Application.runKoa(...);

// enable or disable.
middleware_cors.setEnable(false);