Skip to content

Commit

Permalink
readme update
Browse files Browse the repository at this point in the history
  • Loading branch information
AirBorne04 committed Nov 16, 2022
1 parent 5f6ad9b commit 443f058
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/integrations/cloudflare/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ In order for preview to work you must install `wrangler`
$ 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 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).
It's then possible to update the preview script in your `package.json` to `"preview": "wrangler pages dev ./dist"`. This will allow you 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).

## Access to the Cloudflare runtime

Expand Down Expand Up @@ -111,7 +111,9 @@ export function get({ params }) {

Cloudflare has support for adding custom [headers](https://developers.cloudflare.com/pages/platform/headers/), configuring static [redirects](https://developers.cloudflare.com/pages/platform/redirects/) and defining which routes should [invoke functions](https://developers.cloudflare.com/pages/platform/functions/function-invocation-routes/). Cloudflare looks for `_headers`, `_redirects`, and `_routes.json` files in your build output directory to configure these features. This means they should be placed in your Astro project’s `public/` directory.

The _routes.json file is generated during build to prevent a function invocation on assets paths. This will be overwritten when a custom _routes.json is provided. If that is the case the static files will still be served, but the request will go through a function invocation and will count against the request limits of your Cloudflare plan.
### Custom `_routes.json`

By default, `@astrojs/cloudflare` will generate a `_routes.json` file that lists all files from your `dist` folder in the respective exclude section. This will enable Cloudflare to serve files without a function invocation and therefore not count against the request limits of your Cloudflare plan. Creating a custom `_routes.json` will override this automatic optimization and, if not configured manually, cause function invocations and therefore count against the request limits of your Cloudflare plan.

## Troubleshooting

Expand Down

0 comments on commit 443f058

Please sign in to comment.