Skip to content

Instantly share code, notes, and snippets.

@noherczeg
Last active January 19, 2020 14:03
Show Gist options
  • Save noherczeg/233c7b84cf880efa57ddb3c524992fd1 to your computer and use it in GitHub Desktop.
Save noherczeg/233c7b84cf880efa57ddb3c524992fd1 to your computer and use it in GitHub Desktop.
  • register domain with godaddy
  • disable lock in Domain Settings > Additional Settings (otherwise cloudflare cannot take over)
  • cloudflare: add domain
  • godaddy: DNS > Manage Zones > provide name > Nnameservers > Change > provide 2 cloudflare DNS server addresses
  • subscribe to workers unlimited plan (otherwise you cannot use workers sites)

Wrangler

Example .toml file

Worker will be named after the folder, not the entry-point!

name = "static-test"
type = "webpack"
account_id = "${YOUR_ACCOUNT_ID}"
workers_dev = true

[site]
bucket = "./src" # this can differ based on project
entry-point = "workers-site"

[env.production]
# The ID of your domain you're deploying to
zone_id = "${YOUR_ZONE_ID}"
# The route pattern your Workers application will be served at
route = "test.whatever.com/*" # this will create the worker if it does not exist yet

Routing Worker to domain:

initially you may need to wait a few seconds for workers to appear in cloudflare combo boxes

  • select domain > Workers > Add Route
    • Route: test.whatever.com/*
    • Worker: ${FOLDER_NAME}-production

Adding sub-domain:

  • select domain > DNS > Add Record
    • Type: CNAME
    • Name: test
    • Target: @
    • Proxy Status: Proxied
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment