1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| 'use strict';
|
| module.exports = app => {
| // put before other core middlewares
| app.config.coreMiddlewares.unshift('cors');
|
| // if security plugin enabled, and origin config is not provided, will only allow safe domains support CORS.
| app.config.cors.origin = app.config.cors.origin || function corsOrigin(ctx) {
| const origin = ctx.get('origin');
| if (!ctx.isSafeDomain || ctx.isSafeDomain(origin)) {
| return origin;
| }
| return '';
| };
| };
|
|