1 | async function cors(ctx, next) {
|
2 | ctx.set('Access-Control-Allow-Origin', '*');
|
3 | ctx.set('Access-Control-Allow-Methods', 'GET,POST,PUT,DELETE,OPTIONS,PATCH');
|
4 | ctx.set('Access-Control-Allow-Headers',
|
5 | 'Content-Type,Content-Length,Accept,Accept-Charset,Accept-Encoding,Authorization,X-Requested-With,Token'
|
6 | );
|
7 | ctx.set('Access-Control-Allow-Credentials', 'true');
|
8 | ctx.set('Access-Control-Max-Age', '7200');
|
9 | if (ctx.request.method === 'OPTIONS') {
|
10 | ctx.body = 'OK';
|
11 | return;
|
12 | }
|
13 | await next();
|
14 | }
|
15 |
|
16 | module.exports = cors; |
\ | No newline at end of file |