-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow landing page to be configured with a precomputed nonce (fix for…
… CF workers) (#7601) #7539 introduced a `v4()` call from the `uuid` package which broke CF workers (apollo-server-integrations/apollo-server-integration-cloudflare-workers#37). This change allows users to configure / precompute the `nonce` in advance to avoid making crypto-y calls on startup (which CF workers throws errors about).
- Loading branch information
1 parent
51b79ac
commit 75b668d
Showing
4 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
'@apollo/server': patch | ||
--- | ||
|
||
Provide a new configuration option for landing page plugins `precomputedNonce` which allows users to provide a nonce and avoid calling into `uuid` functions on startup. This is useful for Cloudflare Workers where random number generation is not available on startup (only during requests). Unless you are using Cloudflare Workers, you can ignore this change. | ||
|
||
The example below assumes you've provided a `PRECOMPUTED_NONCE` variable in your `wrangler.toml` file. | ||
|
||
Example usage: | ||
```ts | ||
const server = new ApolloServer({ | ||
// ... | ||
plugins: [ | ||
ApolloServerPluginLandingPageLocalDefault({ | ||
precomputedNonce: PRECOMPUTED_NONCE | ||
}) | ||
], | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters