feat(desktop-client): fall back to authenticated desktop asset endpoint

When a public asset URL fails (e.g. stale signed token), retry via the
new /api/desktop/content/assets endpoint with the desktop Bearer token
so editor images keep rendering across token rotations.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-27 12:21:02 +08:00
parent acf7738bdd
commit b4cfc6f992
3 changed files with 70 additions and 6 deletions
@@ -147,6 +147,24 @@ export function resolveDesktopApiURL(path: string): string {
return resolveDesktopURL(path);
}
export async function fetchDesktopApiURL(input: string | URL, init: RequestInit = {}): Promise<Response> {
const headers = new Headers(init.headers);
if (transportSession.clientToken && !headers.has("Authorization")) {
headers.set("Authorization", `Bearer ${transportSession.clientToken}`);
}
const url =
input instanceof URL
? input.toString()
: /^https?:\/\//i.test(input)
? input
: resolveDesktopURL(input);
return fetch(url, {
...init,
headers,
});
}
function resolveObservedRequestURL(path: string | undefined, baseURL: string): string {
if (!path) {
return baseURL;