Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add customizable header command #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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.
  • Loading branch information
code-asher committed Aug 18, 2023
commit c67bca29653dabd88b7f8b4905b25e11e96073a1
11 changes: 4 additions & 7 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,10 @@ export async function activate(ctx: vscode.ExtensionContext): Promise<void> {

// Add headers from the header command.
axios.interceptors.request.use(async (config) => {
return {
...config,
headers: {
...(await storage.getHeaders()),
...creds.headers,
},
}
Object.entries(await storage.getHeaders()).forEach(([key, value]) => {
config.headers[key] = value
})
return config
})

const myWorkspacesProvider = new WorkspaceProvider(WorkspaceQuery.Mine, storage)
Expand Down
2 changes: 1 addition & 1 deletion src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ export class Storage {
}
}

public async getHeaders(url = this.getURL()): Promise<Record<string, string> | undefined> {
public async getHeaders(url = this.getURL()): Promise<Record<string, string>> {
return getHeaders(url, vscode.workspace.getConfiguration().get("coder.headerCommand"), this)
}
}
Expand Down