@jayfong/x-server 2.52.0 → 2.52.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/_cjs/plugins/cors.js +2 -1
- package/lib/plugins/cors.d.ts +3 -2
- package/lib/plugins/cors.js +3 -2
- package/package.json +1 -1
package/lib/_cjs/plugins/cors.js
CHANGED
|
@@ -29,7 +29,8 @@ class CorsPlugin {
|
|
|
29
29
|
});
|
|
30
30
|
fastify.register(_cors.default, {
|
|
31
31
|
origin: (origin, cb) => allowAll ? cb(null, true) : cb(null, origin ? check(origin) : true),
|
|
32
|
-
maxAge: (0, _vtils.ms)(this.options.ttl, true)
|
|
32
|
+
maxAge: (0, _vtils.ms)(this.options.ttl, true),
|
|
33
|
+
...(0, _vtils.omitStrict)(this.options, ['allow', 'ttl'])
|
|
33
34
|
});
|
|
34
35
|
}
|
|
35
36
|
}
|
package/lib/plugins/cors.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FastifyCorsOptions } from '@fastify/cors';
|
|
2
2
|
import { FastifyInstance } from 'fastify';
|
|
3
3
|
import { MsValue } from 'vtils';
|
|
4
|
-
|
|
4
|
+
import { BasePlugin } from './base';
|
|
5
|
+
export interface CorsPluginOptions extends FastifyCorsOptions {
|
|
5
6
|
/**
|
|
6
7
|
* 允许的来源,支持位于开头的 * 通配符
|
|
7
8
|
*/
|
package/lib/plugins/cors.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import FastifyCors from '@fastify/cors';
|
|
2
|
-
import { memoize } from 'vtils';
|
|
2
|
+
import { memoize, omitStrict } from 'vtils';
|
|
3
3
|
import { ms } from 'vtils';
|
|
4
4
|
/**
|
|
5
5
|
* CORS 支持插件
|
|
@@ -25,7 +25,8 @@ export class CorsPlugin {
|
|
|
25
25
|
});
|
|
26
26
|
fastify.register(FastifyCors, {
|
|
27
27
|
origin: (origin, cb) => allowAll ? cb(null, true) : cb(null, origin ? check(origin) : true),
|
|
28
|
-
maxAge: ms(this.options.ttl, true)
|
|
28
|
+
maxAge: ms(this.options.ttl, true),
|
|
29
|
+
...omitStrict(this.options, ['allow', 'ttl'])
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
}
|