Skip to content

Commit

Permalink
Note private env var handling with cloudflare builds (#4490)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy authored Aug 26, 2022
1 parent a58cdcb commit 2d2e29d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/integrations/cloudflare/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,17 @@ In order to work around this:
- install the `"web-streams-polyfill"` package
- add `import "web-streams-polyfill/es2018";` to the top of the front matter of every page which requires streams, such as server rendering a React component.

## Environment Variables

As Cloudflare Pages Functions [provides environment variables differently](https://developers.cloudflare.com/pages/platform/functions/#adding-environment-variables-locally), private environment variables needs to be set through [`vite.define`](https://vitejs.dev/config/shared-options.html#define) to work in builds.

```js
// astro.config.mjs
export default {
vite: {
define: {
'process.env.MY_SECRET': JSON.stringify(process.env.MY_SECRET),
},
},
}
```

0 comments on commit 2d2e29d

Please sign in to comment.