diff --git a/packages/bsky/src/api/app/bsky/feed/getFeed.ts b/packages/bsky/src/api/app/bsky/feed/getFeed.ts index 5100ec0f5ab..562cec6baa4 100644 --- a/packages/bsky/src/api/app/bsky/feed/getFeed.ts +++ b/packages/bsky/src/api/app/bsky/feed/getFeed.ts @@ -38,14 +38,21 @@ export default function (server: Server, ctx: AppContext) { const db = ctx.db.getReplica() const feedService = ctx.services.feed(db) const viewer = auth.credentials.iss - + const headers: Record = {} + const headersToForward = ['authorization', 'accept-language'] + for (const header of headersToForward) { + const value = req.headers[header] + if (typeof value === 'string') { + headers[header] = value + } + } const { timerSkele, timerHydr, ...result } = await getFeed( { ...params, viewer }, { db, feedService, appCtx: ctx, - authorization: req.headers['authorization'], + headers, }, ) @@ -127,7 +134,7 @@ type Context = { db: Database feedService: FeedService appCtx: AppContext - authorization?: string + headers: Record } type Params = GetFeedParams & { viewer: string | null } @@ -147,7 +154,7 @@ const skeletonFromFeedGen = async ( ctx: Context, params: GetFeedParams, ): Promise => { - const { db, appCtx, authorization } = ctx + const { db, appCtx, headers } = ctx const { feed } = params // Resolve and fetch feed skeleton const found = await db.db @@ -185,9 +192,6 @@ const skeletonFromFeedGen = async ( let skeleton: SkeletonOutput try { // @TODO currently passthrough auth headers from pds - const headers: Record = authorization - ? { authorization: authorization } - : {} const result = await agent.api.app.bsky.feed.getFeedSkeleton(params, { headers, }) diff --git a/packages/pds/src/api/app/bsky/feed/getFeed.ts b/packages/pds/src/api/app/bsky/feed/getFeed.ts index 82bb2e30b16..3f525b81524 100644 --- a/packages/pds/src/api/app/bsky/feed/getFeed.ts +++ b/packages/pds/src/api/app/bsky/feed/getFeed.ts @@ -4,7 +4,7 @@ import AppContext from '../../../../context' export default function (server: Server, ctx: AppContext) { server.app.bsky.feed.getFeed({ auth: ctx.authVerifier.access, - handler: async ({ params, auth }) => { + handler: async ({ req, params, auth }) => { const requester = auth.credentials.did const { data: feed } = @@ -12,9 +12,24 @@ export default function (server: Server, ctx: AppContext) { { feed: params.feed }, await ctx.appviewAuthHeaders(requester), ) + const serviceAuthHeaders = await ctx.serviceAuthHeaders( + requester, + feed.view.did, + ) + const headers: Record = {} + const headersToForward = ['accept-language'] + for (const header of headersToForward) { + const value = req.headers[header] + if (typeof value === 'string') { + headers[header] = value + } + } + const feedOpts = { + headers: { ...headers, ...serviceAuthHeaders.headers }, + } const res = await ctx.appViewAgent.api.app.bsky.feed.getFeed( params, - await ctx.serviceAuthHeaders(requester, feed.view.did), + feedOpts, ) return { encoding: 'application/json',