Commit aa655c0
fix(moryflow/server): whitelist headers for originless POST to Better Auth (#230)
Previous blacklist-based cookie stripping failed because reverse proxies
(1panel/nginx) can inject arbitrary headers (cookies, Sec-Fetch-*) that
trigger Better Auth's formCsrfMiddleware with forceValidate=true, which
then rejects the request with "Missing or null Origin".
Switch to whitelist approach: for POST requests without Origin (device or
server-to-server calls that never come from a browser), build Better Auth
request headers from scratch with only known-safe headers. This eliminates
all proxy-injected interference regardless of what the proxy adds.
Legitimate browser POSTs always include Origin, so they continue to use
the full header passthrough path unchanged.
Co-authored-by: Codex <[email protected]>1 parent 3ede683 commit aa655c0
1 file changed
+49
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
63 | 69 | | |
64 | 70 | | |
65 | 71 | | |
| |||
275 | 281 | | |
276 | 282 | | |
277 | 283 | | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
278 | 288 | | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
284 | 294 | | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
292 | 321 | | |
293 | 322 | | |
294 | | - | |
| 323 | + | |
295 | 324 | | |
296 | 325 | | |
297 | 326 | | |
| |||
0 commit comments