diff options
| author | Kit Langton <[email protected]> | 2026-05-03 17:13:42 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-05-03 21:13:42 +0000 |
| commit | ca6150d6f092cc8761d6072b0b07b6a7de8748cf (patch) | |
| tree | 2e62b173530b8bb8f1d0d9583764217d3b7a888b /packages/app/src/entry.tsx | |
| parent | 825ab2e38d1f41074bb536b6ba5771f30594b197 (diff) | |
| download | opencode-ca6150d6f092cc8761d6072b0b07b6a7de8748cf.tar.gz opencode-ca6150d6f092cc8761d6072b0b07b6a7de8748cf.zip | |
fix(app): preserve auth token credentials (#25636)
Diffstat (limited to 'packages/app/src/entry.tsx')
| -rw-r--r-- | packages/app/src/entry.tsx | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/packages/app/src/entry.tsx b/packages/app/src/entry.tsx index ade572c2f..5115f0348 100644 --- a/packages/app/src/entry.tsx +++ b/packages/app/src/entry.tsx @@ -7,6 +7,7 @@ import { type Platform, PlatformProvider } from "@/context/platform" import { dict as en } from "@/i18n/en" import { dict as zh } from "@/i18n/zh" import { handleNotificationClick } from "@/utils/notification-click" +import { authFromToken } from "@/utils/server" import pkg from "../package.json" import { ServerConnection } from "./context/server" @@ -111,6 +112,13 @@ const getDefaultUrl = () => { return getCurrentUrl() } +const clearAuthToken = () => { + const params = new URLSearchParams(location.search) + if (!params.has("auth_token")) return + params.delete("auth_token") + history.replaceState(null, "", location.pathname + (params.size ? `?${params}` : "") + location.hash) +} + const platform: Platform = { platform: "web", version: pkg.version, @@ -146,7 +154,16 @@ if (import.meta.env.VITE_SENTRY_DSN) { } if (root instanceof HTMLElement) { - const server: ServerConnection.Http = { type: "http", http: { url: getCurrentUrl() } } + const auth = authFromToken(new URLSearchParams(location.search).get("auth_token")) + clearAuthToken() + const server: ServerConnection.Http = { + type: "http", + authToken: !!auth, + http: { + url: getCurrentUrl(), + ...auth, + }, + } render( () => ( <PlatformProvider value={platform}> |
