Add Cloudflare adapter section to advanced routing docs#13912
Conversation
Lunaria Status Overview🌕 This pull request will trigger status changes. Learn moreBy default, every PR changing files present in the Lunaria configuration's You can change this by adding one of the keywords present in the Tracked Files
Warnings reference
|
florian-lefebvre
left a comment
There was a problem hiding this comment.
I think this section should mention how that interacts with main in wrangler.jsonc. Like you probably don't want to use this and @astrojs/cloudflare/utils/handler at the same time
✅ Deploy Preview for astro-docs-2 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for astro-docs-2 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@florian-lefebvre I added a short explanation in 8f90f76. Let me know if you think it deserves more of an explanation, hard to describe. |
…ing.mdx Co-authored-by: Armand Philippot <git@armand.philippot.eu>
florian-lefebvre
left a comment
There was a problem hiding this comment.
I think that's better thank you!
|
|
||
| The [`@astrojs/cloudflare`](/en/guides/integrations-guide/cloudflare/) adapter provides companion handlers that apply Cloudflare-specific setup to your advanced routing pipeline. These handlers configure session KV binding injection, static asset serving via the `ASSETS` binding, `Astro.locals.cfContext`, client address from the `cf-connecting-ip` header, `waitUntil`, and prerendered error page fetching. | ||
|
|
||
| You can use the `astro/fetch` and `astro/hono` APIs from `src/app.ts` on Cloudflare without these handlers. The adapter's default entrypoint takes care of Cloudflare-specific setup for you. These companion handlers are useful when you already have a [custom worker entrypoint](https://developers.cloudflare.com/workers/runtime-apis/handlers/fetch/) (`src/worker.ts`), for example to export a Durable Object, and want to use the advanced routing APIs directly from that file instead. |
There was a problem hiding this comment.
I'm not a Cloudflare user so that might explain my confusion, but is https://developers.cloudflare.com/workers/runtime-apis/handlers/fetch/ the link you wanted to put here? I mean this page doesn't mention custom worker entrypoint at all so the link anchor seems strange to me.
Do users need to define experimental.advancedRouting.fetchFile with src/worker.ts?
If so, linking to #customizing-the-entrypoint-file might make more sense here.
But, the Cloudflare link seems helpful when we mention cf() in @astrojs/cloudflare/fetch (and probably Hono too).
There was a problem hiding this comment.
No, users do not need to do anything with fetchFile. They wouldn't use that feature since they are using the Wrangler feature.
I see what you mean about the docs, maybe it's better to point to the wrangler config page which shows you how to define your own worker. I'll see if I can find a better link.
There was a problem hiding this comment.
I switched to the wrangler config page.
…ing.mdx Co-authored-by: Yan <61414485+yanthomasdev@users.noreply.github.com>
Description (required)
Documents the new fetch handlers for Cloudflare.
Related issues & labels (optional)
withastro/astro#16729