-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parameterized configuration of cors from dotenv needs full TypeScript support #1506
Comments
I found a few problems with this issue:
|
Hello @CodingDoug. You can use const corsOrigin = defineString('*')
export const hello = onRequest({
cors: corsOrigin.value(),
}, request => {
request.res?.json({hello: 'world'});
}); Does this solve your issue? |
@exaby73 No, it doesn't work because Take, for example, the TypeScript definition of the HttpsOptions object passed to onCreate, and see how it takes various
See that |
I understand your use case here. I will label this as a feature request and let additional insights come in from the team. Thank you :) |
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:
TypeScript will fail at compilation with an error like this:
cors is missing a unioned type for
Expression<string>
like the other string configurations: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 likecorsOrigin 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.
The text was updated successfully, but these errors were encountered: