Commit 68f7125
committed
Run entirely on Cloudflare and drop the Vercel layer
The site is one Worker: worker/index.js serves the built files through the ASSETS
binding and handles /api/admin/*. Readers never reach it - the catalogue and every
chapter are static objects on R2 behind the CDN - so the Worker exists for the
admin panel, not for reading.
Deleted: all eleven api/ functions, vercel.json, server/server.js, the three Blob
modules, the blob-to-R2 migration script, and the Pages functions/ directory that
a Workers project does not route. @vercel/blob and express are gone from
package.json, which now has one runtime dependency.
Handlers reuse the modules under server/ rather than reimplementing them, which
nodejs_compat makes possible. That was worth verifying rather than assuming:
workerd's scrypt, HMAC and base64url all produce byte-identical output to Node's,
so the existing password hash stays valid and there is one implementation of
signing, session verification and presigning instead of two. The duplicate Web
Crypto signer I had written for Pages is therefore deleted.
Two R2 bindings replace signing for reads and writes, so crawler config and the
catalogue snapshot go through env.NOVEL_STORAGE / env.NOVEL_ARCHIVE. Presigning
still uses the S3 credentials, because a binding cannot presign and a 200 MB EPUB
must not pass through a Worker that caps request bodies at 100 MB.
Behaviour changes forced by the removal, rather than chosen:
- On-demand translation is gone. It needed a server that could call Gemini;
translation now happens once at ingest, in Actions. The reader says so instead
of failing on a dead endpoint.
- The library no longer falls back to /api/library, so loadCatalogSnapshot is no
longer gated on READER_CDN_ENABLED. That flag decides where chapters are read
from; gating the catalogue on it left the shelf empty with the flag off.
- Analytics inserts straight into Supabase with the anon key and has no fallback.
- Admin catalogue and analytics need SUPABASE_SERVICE_ROLE_KEY on the Worker, and
return an explicit 503 or an empty answer without it rather than failing
obscurely. It is a Worker secret, never inlined into a bundle.
- Per-IP login throttling is gone. Its counter was a module-level Map, which does
nothing across isolates; the constant-time failure delay stays.
Also fixed here:
- The crawler no longer calls any website. SITE_URL, CRAWLER_SECRET, the OIDC
token dance and the metadata fallback are all removed, which retires the JWKS
rotation bug rather than working around it.
- %CDN_ORIGIN% was substituted only when followed by a space, so removing the
last source after it shipped the literal placeholder in img-src. The separator
is now consumed with the token, checked with and without an origin.
- The build prints which reader mode it produced. The flag is inlined, so nothing
in the output showed it, and public/ is committed - it was possible to ship a
CDN-enabled bundle by accident. This commit ships READER_CDN_ENABLED unset.
- .wrangler/ and .dev.vars are ignored; local R2 state was staged for commit.
Verified: clean npm install, build emits "(cdn: https://cdn.tram-chu.online)",
wrangler reads 24 assets and bundles the Worker with no warnings, and workerd
serves the real thing - wrong password 401, correct password 200 with a
HttpOnly/Secure/SameSite=Strict cookie, presigned PUT into the private bucket with
no secret in the URL, crawler config written to and read back from the R2 binding,
ingest dispatch 503 without a token. 118 tests pass, and no secret appears in any
browser bundle.1 parent 9c68a22 commit 68f7125
54 files changed
Lines changed: 1222 additions & 4315 deletions
File tree
- .github/workflows
- api
- admin
- crawler
- client
- docs
- functions
- _lib
- api/admin
- public
- scripts
- migration
- server
- worker
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
3 | 4 | | |
4 | | - | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
12 | | - | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
17 | | - | |
| 19 | + | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| |||
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
29 | | - | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
32 | 44 | | |
33 | 45 | | |
34 | | - | |
35 | | - | |
| 46 | + | |
| 47 | + | |
36 | 48 | | |
37 | 49 | | |
38 | | - | |
| 50 | + | |
| 51 | + | |
39 | 52 | | |
40 | 53 | | |
41 | 54 | | |
| 55 | + | |
| 56 | + | |
42 | 57 | | |
43 | 58 | | |
44 | 59 | | |
45 | 60 | | |
46 | 61 | | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | 62 | | |
54 | 63 | | |
55 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | 28 | | |
30 | 29 | | |
31 | | - | |
32 | | - | |
33 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
34 | 33 | | |
35 | 34 | | |
36 | 35 | | |
| |||
39 | 38 | | |
40 | 39 | | |
41 | 40 | | |
42 | | - | |
43 | | - | |
| 41 | + | |
| 42 | + | |
44 | 43 | | |
45 | 44 | | |
46 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
| 126 | + | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
130 | 130 | | |
131 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
132 | 134 | | |
133 | | - | |
| 135 | + | |
134 | 136 | | |
135 | 137 | | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
| 138 | + | |
| 139 | + | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
143 | 147 | | |
144 | 148 | | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
| 149 | + | |
150 | 150 | | |
151 | 151 | | |
152 | | - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
153 | 161 | | |
154 | | - | |
| 162 | + | |
155 | 163 | | |
156 | | - | |
157 | | - | |
| 164 | + | |
158 | 165 | | |
159 | 166 | | |
160 | 167 | | |
161 | 168 | | |
162 | 169 | | |
163 | 170 | | |
164 | 171 | | |
165 | | - | |
| 172 | + | |
| 173 | + | |
166 | 174 | | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
| 175 | + | |
171 | 176 | | |
172 | | - | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
173 | 182 | | |
174 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
175 | 187 | | |
176 | 188 | | |
177 | 189 | | |
178 | | - | |
| 190 | + | |
179 | 191 | | |
180 | | - | |
| 192 | + | |
181 | 193 | | |
182 | | - | |
| 194 | + | |
183 | 195 | | |
184 | 196 | | |
185 | 197 | | |
| |||
202 | 214 | | |
203 | 215 | | |
204 | 216 | | |
205 | | - | |
| 217 | + | |
206 | 218 | | |
207 | 219 | | |
208 | 220 | | |
209 | 221 | | |
210 | 222 | | |
211 | 223 | | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | 224 | | |
233 | 225 | | |
234 | 226 | | |
235 | 227 | | |
236 | | - | |
| 228 | + | |
237 | 229 | | |
238 | | - | |
| 230 | + | |
0 commit comments