Commit 68bd764
authored
fix: add has trap to lazy auth proxy so auth routes resolve handler (#139)
* fix: add has trap to lazy auth proxy so auth routes resolve handler
The lazy `auth` Proxy only trapped `get`, leaving `has` to forward to its
empty target. better-auth's `toNextJsHandler` checks `"handler" in auth`
per request; that returned false, so it fell through to calling
`auth(request)`, which isn't callable. Result: every /api/auth/* POST threw
"TypeError: ... is not a function" in production (e.g. sign-in/social).
Add a `has` trap forwarding to the real instance. Stays build-time safe: the
check only runs inside toNextJsHandler's per-request closure, never at module
load, so env-validation decoupling is preserved.
* fix: type lazy proxy get-traps to satisfy no-unsafe lint
The get-traps assigned `Reflect.get(...)`'s `any` return, tripping
@typescript-eslint/no-unsafe-{assignment,return,call,member-access} (12
errors, pre-existing red on main since the proxies landed). Annotate the
forwarded value as `unknown` and cast on the function branch so binding is
type-checked. Runtime behavior is unchanged.1 parent 7afa7e0 commit 68bd764
2 files changed
Lines changed: 15 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
82 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
83 | 88 | | |
84 | 89 | | |
85 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| |||
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
58 | | - | |
59 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
60 | 64 | | |
61 | 65 | | |
62 | 66 | | |
| |||
0 commit comments