LAB GUIDE / SECTION 02
Deploy your Worker
2.1 One click → repo + live Worker#
Your Worker starts from the class template repo: https://github.com/RoderickOxen/iscte-workers-template. You don't clone that one or change it. The button below makes your own copy of it.
On the deploy page:
- Connect GitHub when asked, and allow access to your account.
- Project name (and repo name, if asked separately): type
<your-droid-name>, your Droid Name. - Click Deploy and wait about a minute.
That's all it asks for: names, and nothing secret. There are no API keys in this class.
In that one click, Cloudflare:
- copied the template into a new repo on your GitHub:
github.com/<your-github-user>/<your-droid-name>. It's yours: not a fork, no link back to the template, - built and deployed it to your Cloudflare account,
- set up Workers Builds: from now on, every
git pushto your repo redeploys your Worker automatically.
| Template repo (the teacher's) | Your repo | |
|---|---|---|
| URL | github.com/RoderickOxen/iscte-workers-template | github.com/<your-github-user>/<your-droid-name> |
| You… | used it once, through the button | clone it, edit it, push to it |
| Deploys | nothing | your Worker, on every push |
Open the URL it shows you. It should be https://<your-droid-name>.<your-subdomain>.workers.dev. You're on the internet.
Tip
Different URL from the one above (another name, a changed subdomain)? Fix it in Your project at the top of the page, so every command later in the guide is right.
2.2 Get the code on your laptop#
Clone your repo, the copy the button just made, not the template:
git clone https://github.com/<your-github-user>/<your-droid-name>.git
cd <your-droid-name>
npm install2.3 Run it locally#
npm run dev # same as: npx wrangler devOpen http://localhost:8787. It's the same page, running on your laptop in the same runtime Cloudflare uses (workerd). Edit, save, refresh: changes appear instantly.
You'll see a Droid ID card with every row saying "unknown", and a hint box: "Character: unknown. Finish Mission 2 to load your character." That's expected. You'll fill the card in during Mission 2.
Two things to notice:
- Your Pixel Droid (the little robot next to your name) looks different on localhost. It's drawn from your Worker's URL, and
localhostis a different URL. Once you deploy, it matches the one the Hub shows in the Directory. - The button at the top right switches between light, dark and system themes.
Note
Wrangler may ask you to log in again, or which account to use. Your Worker has an AI binding, and Wrangler connects to Cloudflare for it even in local dev. Pick the account you created today. Stuck? See Troubleshooting.
Check#
- https://<your-droid-name>.<your-subdomain>.workers.dev loads (placeholder name, an empty ID card with a hint)
- The footer says Served from a three-letter code: the Cloudflare data centre nearest you (probably
LIS). Check this on your live URL: locally it shows something else, because your laptop is the data centre. Open it through a VPN in another country and the code changes, even though you only deployed once - http://localhost:8787 loads too
Something failed?
- Deploy page asks you to create a workers.dev subdomain: you skipped step 1.1.4. Pick a short name, then update Cloudflare subdomain under Your project at the top of this page, so your URLs here are right.
npm run devasks which account, or fails with an account error: you have several Cloudflare accounts. See Troubleshooting.- Build failed: in the Cloudflare dashboard go to Workers & Pages → your Worker → Deployments → View build and read the log. Most often it's an unverified email.
npm run devport in use:npx wrangler dev --port 8788.
Next: Make it yours
Checks are saved automatically on this browser.