Commit fd23b13
fix(cloud/frontend): StewardProvider syncs steward-session cookie to api.elizacloud.ai (#7360)
* fix(cloud/frontend): use apiFetch for /api/auth/steward-session so cookie sets on api.elizacloud.ai
Follow-up to #7358. setSessionCookie was still calling raw
fetch("/api/auth/steward-session"), which goes same-origin to
www.elizacloud.ai. The Worker sets steward-token + steward-authed
cookies on the host the Set-Cookie response came from, so they
end up host-only on www.elizacloud.ai.
Subsequent apiFetch calls (e.g. /api/auth/cli-session/<id>/complete)
now go cross-origin to api.elizacloud.ai (per #7358 SPA-direct
behaviour). The host-only www cookie does not flow on that
cross-origin request, the request 401s, and the CLI login screen
deadlocks at "Generating API Key" until the 30s client timeout
fires.
Switch setSessionCookie to apiFetch so the cookie-setting POST
also goes to api.elizacloud.ai. The Set-Cookie response is now
scoped to the same host that all subsequent /api/* calls hit.
Production deploy verified: /api/auth/cli-session/<id>/complete
returns 200 with the cookie attached, login flow unblocks past
"Generating API Key".
Co-authored-by: wakesync <shadow@shad0w.xyz>
* fix(cloud/frontend): StewardProvider syncs steward-session cookie to api.elizacloud.ai
Follow-up to #7359. The login form's setSessionCookie was switched to
apiFetch in #7359, but StewardProvider has its own auto-sync useEffect
that POSTs the localStorage token to /api/auth/steward-session via raw
fetch. That request still goes same-origin to www.elizacloud.ai so the
Set-Cookie response is scoped host-only to www. Then when the
/auth/cli-login page's completeCliLogin sends apiFetch to
api.elizacloud.ai, the host-only www cookie does not flow on the
cross-origin request. The CLI login spinner deadlocks at
'Generating API Key' until the 30s client timeout fires.
Same root cause, second seam.
Add a stewardSessionUrl helper that returns the absolute Workers
origin (https://api.elizacloud.ai/api/auth/steward-session) when the
SPA is running on a known elizacloud.ai host, and fall back to the
relative same-origin path everywhere else (dev, preview, ad-hoc
hosts).
All four steward-session calls in StewardProvider (one POST sync,
three DELETE wipes) now go through stewardSessionUrl with explicit
credentials: 'include'. Cookies set on api.elizacloud.ai by the POST
flow with subsequent apiFetch calls.
Verified live on production deploy 60caf2a0:
- www.elizacloud.ai/api/health -> 200 JSON
- www.elizacloud.ai/steward/auth/providers -> 200 JSON
- /auth/cli-login completes the spinner past 'Generating API Key'
Co-authored-by: wakesync <shadow@shad0w.xyz>
---------
Co-authored-by: wakesync <shadow@shad0w.xyz>1 parent 5c405c9 commit fd23b13
1 file changed
Lines changed: 30 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
8 | 31 | | |
9 | 32 | | |
10 | 33 | | |
| |||
134 | 157 | | |
135 | 158 | | |
136 | 159 | | |
137 | | - | |
| 160 | + | |
138 | 161 | | |
139 | 162 | | |
140 | 163 | | |
| |||
175 | 198 | | |
176 | 199 | | |
177 | 200 | | |
178 | | - | |
| 201 | + | |
179 | 202 | | |
180 | 203 | | |
181 | 204 | | |
| |||
192 | 215 | | |
193 | 216 | | |
194 | 217 | | |
195 | | - | |
| 218 | + | |
196 | 219 | | |
| 220 | + | |
197 | 221 | | |
198 | 222 | | |
199 | 223 | | |
| |||
266 | 290 | | |
267 | 291 | | |
268 | 292 | | |
269 | | - | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
270 | 296 | | |
271 | 297 | | |
272 | 298 | | |
| |||
0 commit comments