Skip to content

Commit a77bdd9

Browse files
authored
Merge pull request #114 from blacksky-algorithms/fix/prefs-not-proxied
fix: don't proxy getPreferences/putPreferences to the appview
2 parents 5225601 + 4675aaa commit a77bdd9

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/state/session/agent.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,26 @@ class BskyAppAgent extends BskyAgent {
350350
super({
351351
service,
352352
async fetch(...args) {
353+
// PDS-local prefs methods must not carry the appview proxy header.
354+
const input = args[0] as string | URL | Request
355+
const url =
356+
typeof input === 'string'
357+
? input
358+
: input instanceof URL
359+
? input.href
360+
: input.url
361+
if (
362+
url &&
363+
(url.includes('app.bsky.actor.getPreferences') ||
364+
url.includes('app.bsky.actor.putPreferences'))
365+
) {
366+
const init = args[1] as RequestInit | undefined
367+
if (init?.headers) {
368+
const headers = new Headers(init.headers)
369+
headers.delete('atproto-proxy')
370+
init.headers = headers
371+
}
372+
}
353373
let success = false
354374
try {
355375
const result = await realFetch(...args)

0 commit comments

Comments
 (0)