| 1 | # Cloudflare Website service bindings |
| 2 | |
| 3 | One stack runs nine Websites together, each behind its own Gateway Worker: |
| 4 | SvelteKit, Nuxt, Next.js HMR, Next.js preview, Octane, Astro, Waku, Vocs, and Vinext. |
| 5 | The small apps live in `apps/`, with independent dependencies and build directories. |
| 6 | |
| 7 | Each Website has `workersDev: false` and caching enabled. Its uncached Gateway |
| 8 | forwards requests with `env.WEBSITE.fetch(request)`. The stack outputs each pair's |
| 9 | `websiteUrl` and `gatewayUrl`; the Website URL is only available in local dev. |
| 10 | Local ports are allocated automatically. State is stored locally. |
| 11 | |
| 12 | ## Commands |
| 13 | |
| 14 | From this directory: |
| 15 | |
| 16 | ```sh |
| 17 | vpr dev # start all nine Websites and Gateways together |
| 18 | vpr deploy # deploy the complete stack |
| 19 | vpr destroy # tear down the stack |
| 20 | vpr test # run the standard dev and deployed integration tests |
| 21 | ``` |
| 22 | |
| 23 | This example is included in the repository's normal `vpr test:examples` run. |
| 24 | It uses the same Cloudflare authentication/profile setup as the other examples. |
| 25 | |
| 26 | ## Tests |
| 27 | |
| 28 | `test/dev.test.ts` starts the whole stack once with `Test.make({ dev: true })`. |
| 29 | It checks every Website directly and then through its Gateway's service binding. |
| 30 | `test/integ.test.ts` deploys the whole stack and checks each Gateway against its |
| 31 | private Website. Both suites destroy their stack after testing. |
| 32 | |
| 33 | The dev tests guard against [#1796](https://github.com/alchemy-run/alchemy/issues/1796): |
| 34 | all nine Gateways must reach their private Websites through local service bindings |
| 35 | and return 200 with the expected page content. |