Merge branch 'main' into refactor-endpoint-response-handling

This commit is contained in:
bluwy 2023-07-07 18:42:54 +08:00
commit e14e9dd1d9
2 changed files with 13 additions and 1 deletions

View file

@ -66,7 +66,7 @@ export default defineConfig({
In order for preview to work you must install `wrangler`
```sh
$ pnpm install wrangler --save-dev
pnpm install wrangler --save-dev
```
It's then possible to update the preview script in your `package.json` to `"preview": "wrangler pages dev ./dist"`. This will allow you to run your entire application locally with [Wrangler](https://github.com/cloudflare/wrangler2), which supports secrets, environment variables, KV namespaces, Durable Objects and [all other supported Cloudflare bindings](https://developers.cloudflare.com/pages/platform/functions/#adding-bindings).

View file

@ -172,6 +172,18 @@ You can pass the path to your key and certification via the environment variable
SERVER_KEY_PATH=./private/key.pem SERVER_CERT_PATH=./private/cert.pem node ./dist/server/entry.mjs
```
#### Runtime environment variables
If an `.env` file containing environment variables is present when the build process is run, these values will be hard-coded in the output, just as when generating a static website.
During the build, the runtime variables must be absent from the `.env` file, and you must provide Astro with every environment variable to expect at run-time: `VARIABLE_1=placeholder astro build`. This signals to Astro that the actual value will be available when the built application is run. The placeholder value will be ignored by the build process, and Astro will use the value provided at run-time.
In the case of multiple run-time variables, store them in a seperate file (e.g. `.env.runtime`) from `.env`. Start the build with the following command:
```sh
export $(cat .env.runtime) && astro build
```
## Troubleshooting
### SyntaxError: Named export 'compile' not found