firebase / firebase/firebase-functions

Feature Request - Add consumeAppCheckToken and CORS in setGlobalOptions

Open
#1,443 3 comments 5 reactions 0 assignees View on GitHub
feature request
Dominant language
TypeScript
Stars
1.1k
Forks
232
Avg merge
20h 46m
Merged PRs (30d)
15

Description

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:

```TypeScript
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](https://firebase.google.com/docs/app-check/cloud-functions#replay-protection).

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](https://firebase.google.com/docs/functions/callable?gen=2nd#cors).

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

The end result would be something like this:

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

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

Thank you for your consideration.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.