Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
feat: decouple preview localhost resolving on runtime (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
wey-gu authored May 11, 2023
1 parent 651b3a5 commit 7a1e757
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/view/PreviewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,14 @@ export class PreviewProvider implements WebviewViewProvider {
}
}
})

let serverAddr = `http://127.0.0.1:${config.port}/`

const serverAddr = `http://localhost:${config.port}/`
const indexUrl = `${serverAddr}index.html`
const resolvedBody = await got.get(indexUrl, { responseType: 'text', resolveBodyOnly: true }).catch(() => null)
if (!resolvedBody) {
serverAddr = `http://[::1]:${config.port}/`
}
const url = `${serverAddr}${idx}?embedded=true`

this.view.webview.html = `
Expand Down

0 comments on commit 7a1e757

Please sign in to comment.