Skip to content

Commit 632f94f

Browse files
authored
fix(opencode): add authorization header to fetch requests in RunCommand (anomalyco#29877)
1 parent a6e3afe commit 632f94f

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

  • packages/opencode/src/cli/cmd

‎packages/opencode/src/cli/cmd/run.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,12 @@ export const RunCommand = effectCmd({
840840
const fetchFn = (async (input: RequestInfo | URL, init?: RequestInit) => {
841841
const { Server } = await import("@/server/server")
842842
const request = new Request(input, init)
843-
return Server.Default().app.fetch(request)
843+
const headers = new Headers(request.headers)
844+
const auth = ServerAuth.header()
845+
if (auth) headers.set("Authorization", auth)
846+
return Server.Default().app.fetch(
847+
new Request(request, { headers }),
848+
)
844849
}) as typeof globalThis.fetch
845850

846851
try {
@@ -875,7 +880,12 @@ export const RunCommand = effectCmd({
875880
const fetchFn = (async (input: RequestInfo | URL, init?: RequestInit) => {
876881
const { Server } = await import("@/server/server")
877882
const request = new Request(input, init)
878-
return Server.Default().app.fetch(request)
883+
const headers = new Headers(request.headers)
884+
const auth = ServerAuth.header()
885+
if (auth) headers.set("Authorization", auth)
886+
return Server.Default().app.fetch(
887+
new Request(request, { headers }),
888+
)
879889
}) as typeof globalThis.fetch
880890
const sdk = createOpencodeClient({
881891
baseUrl: "http://opencode.internal",

0 commit comments

Comments
 (0)