Skip to content

Github Codespace

This doc describes how to set up a Github Codespace for use with Cloudflare Wrangler.

Create Codespace

From https://github.com/codespaces create a new Github Codespace from template.

Setup Cloudflare Token

Setup a Cloudflare Token and configure these rights. Give it a meaningful name.

Alt text

Save Codespace Token

Follow these steps to save the generated token to the Github Codespace: https://docs.github.com/en/codespaces/managing-your-codespaces/managing-secrets-for-your-codespaces

Give the token this name: CLOUDFLARE_API_TOKEN

Start Codespace and install wrangler

The Codespace is a virtual Linux machine. You need to install Wrangler first.

Use the following command:

npm install wrangler --save-dev

Set Cloudflare token in .env

Write this line in the .env file in the same directory as wrangler.toml:

CLOUDFLARE_API_TOKEN=$CLOUDFLARE_API_TOKEN

By using this token, you don't have to use wrangler login to authenticate.