From 443f058f753e4f42e055e5cb63333d2c4b904377 Mon Sep 17 00:00:00 2001 From: AirBorne04 <> Date: Wed, 16 Nov 2022 21:16:00 +0100 Subject: [PATCH] readme update --- packages/integrations/cloudflare/README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 49d6846b5e39f..3d4378c19f683 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -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 @@ -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