Commit 43d12c7
fix(payment-middleware): fail closed when X402_SERVER_ADDRESS missing outside dev (#116)
Closes #112.
Two payment middleware sites silently skipped verification when
X402_SERVER_ADDRESS was missing, intended as a local-dev convenience:
- src/middleware/x402.ts:292 (per-route middleware)
- src/index.ts:305 (global middleware)
If X402_SERVER_ADDRESS were ever unset in staging or production (bad
deploy, secret rotation glitch, env-var migration), all paid endpoints
would silently become free with only a warn log.
Restrict the skip to ENVIRONMENT === "development". In staging and
production, missing config now returns HTTP 503 with code
"NOT_CONFIGURED" instead of fail-opening to free.
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 9f53811 commit 43d12c7
2 files changed
Lines changed: 27 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
305 | | - | |
| 305 | + | |
| 306 | + | |
306 | 307 | | |
307 | | - | |
308 | | - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
309 | 319 | | |
310 | 320 | | |
311 | 321 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
291 | | - | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
292 | 294 | | |
293 | | - | |
294 | | - | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
295 | 306 | | |
296 | 307 | | |
297 | 308 | | |
| |||
0 commit comments