Note private env var handling with cloudflare builds (#4490)
This commit is contained in:
parent
1be49088cc
commit
ba697da4c2
1 changed files with 14 additions and 0 deletions
|
@ -55,3 +55,17 @@ In order to work around this:
|
||||||
- install the `"web-streams-polyfill"` package
|
- 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.
|
- 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),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in a new issue