Description
Version info
node: 18
firebase-functions: 4.5.0
firebase-tools: 13.0.2
[REQUIRED] Steps to reproduce
firebase-functions lacks the correct TypeScript types to do what is stated in the documentation for parameterized configuration. If you try the example code:
// Define some parameters
const corsOrigin = defineString('CORS_ORIGIN');
export const fn = onRequest(
{ cors: corsOrigin },
(req, res) => { ... }
);
TypeScript will fail at compilation with an error like this:
Type 'StringParam' is not assignable to type 'string | boolean | RegExp | (string | RegExp)[] | undefined'.
cors is missing a unioned type for Expression<string>
like the other string configurations:
cors?: string | boolean | RegExp | Array<string | RegExp>;
So it seems impossible to configure cors this way (at least from a compilation perspective - perhaps at runtime the JavaScript will still try to eval a provided StringParam
using a hack like corsOrigin as unknown as string
?).
Secondly, cors takes RegExp and string arrays, and it would be great to be able to configure it using those variants as well. Cors config can vary greatly based on deployment environment.