diff --git a/src/state/session/agent.ts b/src/state/session/agent.ts index 9a850c803..edf86f17b 100644 --- a/src/state/session/agent.ts +++ b/src/state/session/agent.ts @@ -350,6 +350,30 @@ class BskyAppAgent extends BskyAgent { super({ service, async fetch(...args) { + // getPreferences/putPreferences are PDS-local methods. The agent's + // global appview proxy header must not reach them, or a PDS whose + // default appview differs from ours (e.g. bsky.network) forwards them + // to the Blacksky appview, which 501s — breaking the app for accounts + // not hosted on the Blacksky PDS. + const input = args[0] as string | URL | Request + const url = + typeof input === 'string' + ? input + : input instanceof URL + ? input.href + : input.url + if ( + url && + (url.includes('app.bsky.actor.getPreferences') || + url.includes('app.bsky.actor.putPreferences')) + ) { + const init = args[1] as RequestInit | undefined + if (init?.headers) { + const headers = new Headers(init.headers) + headers.delete('atproto-proxy') + init.headers = headers + } + } let success = false try { const result = await realFetch(...args) -- knotmirror 0.0.1 From 4675aaaa7c7afa8e7b5e29e197bafaf73dd99135 Mon Sep 17 00:00:00 2001 From: Rudy Fraser Date: Wed, 8 Jul 2026 15:00:26 -0400 Subject: [PATCH 2/2] style: condense prefs-proxy comment to one line --- src/state/session/agent.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/state/session/agent.ts b/src/state/session/agent.ts index edf86f17b..c0095d751 100644 --- a/src/state/session/agent.ts +++ b/src/state/session/agent.ts @@ -350,11 +350,7 @@ class BskyAppAgent extends BskyAgent { super({ service, async fetch(...args) { - // getPreferences/putPreferences are PDS-local methods. The agent's - // global appview proxy header must not reach them, or a PDS whose - // default appview differs from ours (e.g. bsky.network) forwards them - // to the Blacksky appview, which 501s — breaking the app for accounts - // not hosted on the Blacksky PDS. + // PDS-local prefs methods must not carry the appview proxy header. const input = args[0] as string | URL | Request const url = typeof input === 'string'