Initial scaffold: Cloudflare Pages + Worker + README + wrangler
This commit is contained in:
32
README.md
Normal file
32
README.md
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# Cloudflare Experiment — minimal site + Workers scaffold
|
||||||
|
|
||||||
|
This repository contains a minimal static site and a small Workers scaffold so you can try both Cloudflare Pages and Cloudflare Workers/Wrangler deployments.
|
||||||
|
|
||||||
|
Quick commands
|
||||||
|
|
||||||
|
- Serve locally (simple):
|
||||||
|
```bash
|
||||||
|
python -m http.server 8000
|
||||||
|
# open http://localhost:8000
|
||||||
|
```
|
||||||
|
|
||||||
|
- Cloudflare Pages (quick):
|
||||||
|
1. Push this repo to GitHub/GitLab/Bitbucket.
|
||||||
|
2. In the Cloudflare dashboard → **Pages** → **Create a project**, connect your repo, set the build/publish directory (for this repo: `.`), and deploy.
|
||||||
|
3. Use the provided `<project>.pages.dev` domain, or add a custom domain in the Pages project settings.
|
||||||
|
|
||||||
|
- Cloudflare Workers + Wrangler (quick):
|
||||||
|
```bash
|
||||||
|
# Install wrangler (if needed)
|
||||||
|
npm install -g wrangler
|
||||||
|
wrangler login
|
||||||
|
# Start local dev for the worker
|
||||||
|
cd worker
|
||||||
|
wrangler dev
|
||||||
|
# Publish the worker to workers.dev (requires account_id in wrangler.toml or interactive auth)
|
||||||
|
wrangler publish
|
||||||
|
```
|
||||||
|
|
||||||
|
Notes
|
||||||
|
- Replace placeholders in `wrangler.toml` with your `account_id` and optionally `zone_id` when mapping to a custom domain.
|
||||||
|
- For Pages, no Cloudflare account-level secret is needed; connect via the dashboard.
|
||||||
17
index.html
Normal file
17
index.html
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||||
|
<title>Cloudflare Test Site</title>
|
||||||
|
<style>body{font-family:system-ui,Segoe UI,Helvetica,Arial;color:#111;padding:2rem}</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Cloudflare test site</h1>
|
||||||
|
<p>This is a minimal static site for testing Cloudflare Pages or DNS/proxy setups.</p>
|
||||||
|
<ul>
|
||||||
|
<li>Deploy with Cloudflare Pages (connect this repo)</li>
|
||||||
|
<li>Or serve via any origin and use Cloudflare DNS/proxy</li>
|
||||||
|
</ul>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
11
worker/package.json
Normal file
11
worker/package.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "cloudflare-experiment-worker",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "wrangler dev",
|
||||||
|
"deploy": "wrangler publish"
|
||||||
|
},
|
||||||
|
"devDependencies": {}
|
||||||
|
}
|
||||||
12
worker/src/index.js
Normal file
12
worker/src/index.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
export default {
|
||||||
|
async fetch(request, env, ctx) {
|
||||||
|
return new Response(`<!doctype html>
|
||||||
|
<html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
||||||
|
<title>Cloudflare Worker Test</title></head>
|
||||||
|
<body style="font-family:system-ui,Segoe UI,Helvetica,Arial;padding:2rem">
|
||||||
|
<h1>Cloudflare Worker test</h1>
|
||||||
|
<p>Served from a Cloudflare Worker.</p>
|
||||||
|
</body></html>`,
|
||||||
|
{ headers: { 'content-type': 'text/html; charset=utf-8' } })
|
||||||
|
}
|
||||||
|
}
|
||||||
8
wrangler.toml
Normal file
8
wrangler.toml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
name = "cloudflare-experiment-worker"
|
||||||
|
type = "javascript"
|
||||||
|
# Replace the following with your Cloudflare Account ID after `wrangler login` or from dashboard
|
||||||
|
account_id = "YOUR_ACCOUNT_ID"
|
||||||
|
workers_dev = true
|
||||||
|
# To publish to a custom route set `route` and `zone_id` (remove or leave empty for workers_dev)
|
||||||
|
route = ""
|
||||||
|
zone_id = ""
|
||||||
Reference in New Issue
Block a user