Skip to content

Commit c67bca2

Browse files
committed
Fix merging headers into config object
First, I replaced the wrong line, needed to replace the second one. Secondly, seems you cannot actually spread like this because config.headers actually has a bunch of functions on it.
1 parent 8a56af9 commit c67bca2

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/extension.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,10 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {
6161

6262
// Add headers from the header command.
6363
axios.interceptors.request.use(async (config) => {
64-
return {
65-
...config,
66-
headers: {
67-
...(await storage.getHeaders()),
68-
...creds.headers,
69-
},
70-
}
64+
Object.entries(await storage.getHeaders()).forEach(([key, value]) => {
65+
config.headers[key] = value
66+
})
67+
return config
7168
})
7269

7370
const myWorkspacesProvider = new WorkspaceProvider(WorkspaceQuery.Mine, storage)

src/storage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ export class Storage {
393393
}
394394
}
395395

396-
public async getHeaders(url = this.getURL()): Promise<Record<string, string> | undefined> {
396+
public async getHeaders(url = this.getURL()): Promise<Record<string, string>> {
397397
return getHeaders(url, vscode.workspace.getConfiguration().get("coder.headerCommand"), this)
398398
}
399399
}

0 commit comments

Comments
 (0)