Skip to content

Commit 6db5eda

Browse files
authored
fix(amazonq): 401 errors on windows (#7168)
## Problem 401 and CSP errors when launching hybrid chat on windows ## Solution fix paths --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 1e45112 commit 6db5eda

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

packages/amazonq/src/lsp/chat/webviewProvider.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class AmazonQChatViewProvider implements WebviewViewProvider {
4242
context: WebviewViewResolveContext,
4343
_token: CancellationToken
4444
) {
45-
const lspDir = Uri.parse(LanguageServerResolver.defaultDir())
45+
const lspDir = Uri.file(LanguageServerResolver.defaultDir())
4646
const dist = Uri.joinPath(globals.context.extensionUri, 'dist')
4747

4848
const resourcesRoots = [lspDir, dist]
@@ -54,7 +54,7 @@ export class AmazonQChatViewProvider implements WebviewViewProvider {
5454
const mynahUIPath = getAmazonQLspConfig().ui
5555
if (process.env.WEBPACK_DEVELOPER_SERVER && mynahUIPath) {
5656
const dir = path.dirname(mynahUIPath)
57-
resourcesRoots.push(Uri.parse(dir))
57+
resourcesRoots.push(Uri.file(dir))
5858
}
5959

6060
webviewView.webview.options = {
@@ -68,11 +68,9 @@ export class AmazonQChatViewProvider implements WebviewViewProvider {
6868

6969
this.connectorAdapterPath =
7070
serverHostname !== undefined
71-
? Uri.parse(serverHostname)
72-
.with({ path: `/${source}` })
73-
.toString()
74-
: webviewView.webview.asWebviewUri(Uri.parse(path.join(dist.fsPath, source))).toString()
75-
this.uiPath = webviewView.webview.asWebviewUri(Uri.parse(this.mynahUIPath)).toString()
71+
? `${serverHostname}/${source}`
72+
: webviewView.webview.asWebviewUri(Uri.joinPath(dist, source)).toString()
73+
this.uiPath = webviewView.webview.asWebviewUri(Uri.file(this.mynahUIPath)).toString()
7674

7775
webviewView.webview.html = await this.getWebviewContent()
7876

@@ -105,11 +103,11 @@ export class AmazonQChatViewProvider implements WebviewViewProvider {
105103
const regionProfileString: string = JSON.stringify(regionProfile)
106104

107105
const entrypoint = process.env.WEBPACK_DEVELOPER_SERVER
108-
? 'http: localhost'
109-
: 'https: file+.vscode-resources.vscode-cdn.net'
106+
? 'http://localhost:8080'
107+
: 'https://file+.vscode-resource.vscode-cdn.net'
110108

111109
const contentPolicy = `default-src ${entrypoint} data: blob: 'unsafe-inline';
112-
script-src ${entrypoint} filesystem: ws: wss: 'unsafe-inline';`
110+
script-src ${entrypoint} filesystem: file: vscode-resource: https: ws: wss: 'unsafe-inline';`
113111

114112
return `
115113
<!DOCTYPE html>

0 commit comments

Comments
 (0)