diff --git a/types/index.d.ts b/types/index.d.ts index 0abf15f..9fdcef1 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -2,7 +2,7 @@ import { FastifyInstance, FastifyPluginCallback, FastifyRequest } from 'fastify'; -type OriginCallback = (err: Error | null, allow: boolean) => void; +type OriginCallback = (err: Error | null, origin: ValueOrArray) => void; type OriginType = string | boolean | RegExp; type ValueOrArray = T | ArrayOfValueOrArray; diff --git a/types/index.test-d.ts b/types/index.test-d.ts index 9e83223..6e17445 100644 --- a/types/index.test-d.ts +++ b/types/index.test-d.ts @@ -117,6 +117,18 @@ app.register(fastifyCors, { strictPreflight: false }) +app.register(fastifyCors, { + origin: (origin, cb) => cb(null, true) +}) + +app.register(fastifyCors, { + origin: (origin, cb) => cb(null, '*') +}) + +app.register(fastifyCors, { + origin: (origin, cb) => cb(null, /\*/) +}) + const appHttp2 = fastify({ http2: true }) appHttp2.register(fastifyCors)