You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"passwordHash":null, // SHA-256 of password, or null
@@ -74,32 +80,66 @@ id = "your-production-namespace-id"
74
80
preview_id = "your-preview-namespace-id"
75
81
```
76
82
77
-
### 4. Set the admin password secret
83
+
### Side note: TOML
84
+
85
+
You may have noticed `wrangler.toml` has two cousins, `wrangler.toml.cloud.bac` and `wrangler.toml.local.bac`, This is because when we add a custom domain for production in routes, WRANGLER is really eager to use it, even in dev.
86
+
Running `npm run toml:toggle` or use `dev` and `prod` to switch between the versions. Make sure you enforce parody!
87
+
88
+
### 4. Admin authentication
78
89
79
-
The admin dashboard is protected by HTTP Basic Auth. Set the password via Wrangler:
90
+
Production recommendation: protect the admin dashboard (`/admin`) at the edge (for
91
+
example, using Cloudflare Access). All `/api/*` routes always require HTTP Basic
92
+
Auth and therefore require `ADMIN_SECRET` to be set.
93
+
94
+
To enable local Basic Auth instead of an edge solution (for development or if you
95
+
don't have an edge auth configured), uncomment the local auth block in
96
+
[src/router.js](src/router.js#L752-L792) and set the secret:
80
97
81
98
```bash
82
99
npx wrangler secret put ADMIN_SECRET
83
100
# → Enter your chosen password when prompted
84
101
```
85
102
86
-
When visiting `/admin`, your browser will ask for a username and password.
87
-
Use **any username** and the password you just set.
103
+
Then enable the local flag (in `.dev.vars` or your environment):
104
+
105
+
```
106
+
ADMIN_SECRET=your-local-password
107
+
ENABLE_LOCAL_ADMIN_AUTH=true
108
+
```
109
+
110
+
When enabled, visiting `/admin` will prompt for Basic Auth (any username + the
111
+
password you set). By default the local auth block is commented out in the code
112
+
to avoid accidental exposure in production—uncomment it only if you intend to
0 commit comments