firebase / firebase-functions

Firebase SDK for Cloud Functions
https://firebase.google.com/docs/functions/
MIT License
1.02k stars 202 forks source link

Feature Request - Add consumeAppCheckToken and CORS in setGlobalOptions #1443

Open BenJackGill opened 1 year ago

BenJackGill commented 1 year ago

I am proposing an enhancement for the setGlobalOptions function in Firebase Functions Gen 2.

The setGlobalOptions function enables setting global configurations for the entire project such as enforceAppCheck. For example:

import { setGlobalOptions } from "firebase-functions/v2";

setGlobalOptions({
  enforceAppCheck: true,
});

But I think it would be beneficial to include consumeAppCheckToken and cors options as well.

Adding consumeAppCheckToken will allow developers to fully handle AppCheck at a global level, complementing enforceAppCheck which is already available. Details on consumeAppCheckToken which is currently set at the function level can be found here.

And including cors will provide developers the convenience of managing Cross-Origin Resource Sharing settings across the entire project. Details on cors which is currently set at the function level can be found here.

These enhancements will reduce repetitive individual function configurations, significantly streamlining the development process.

The end result would be something like this:

import { setGlobalOptions } from "firebase-functions/v2";

setGlobalOptions({
  enforceAppCheck: true,
  consumeAppCheckToken: true,
  cors: [/firebase\.com$/, "flutter.com"]
});

Thank you for your consideration.

google-oss-bot commented 1 year ago

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.