From de03314a1a732140feb7b8a8b86633df466fae20 Mon Sep 17 00:00:00 2001 From: davidcooper1 Date: Mon, 14 Feb 2022 01:05:06 -0600 Subject: [PATCH] Use asExternalUri to port forward --- src/arduino/arduinoContentProvider.ts | 2 +- src/arduino/localWebServer.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/arduino/arduinoContentProvider.ts b/src/arduino/arduinoContentProvider.ts index 447ba51b..1818ae9d 100644 --- a/src/arduino/arduinoContentProvider.ts +++ b/src/arduino/arduinoContentProvider.ts @@ -77,7 +77,7 @@ export class ArduinoContentProvider implements vscode.TextDocumentContentProvide var backgroundcolor = styles.getPropertyValue('--background-color') || '#1e1e1e'; var color = styles.getPropertyValue('--color') || '#d4d4d4'; var theme = document.body.className || 'vscode-dark'; - var url = "${this._webserver.getEndpointUri(type)}?" + + var url = "${(await vscode.env.asExternalUri(this._webserver.getEndpointUri(type))).toString()}?" + "theme=" + encodeURIComponent(theme.trim()) + "&backgroundcolor=" + encodeURIComponent(backgroundcolor.trim()) + "&color=" + encodeURIComponent(color.trim()); diff --git a/src/arduino/localWebServer.ts b/src/arduino/localWebServer.ts index 8266abd5..d8b7937d 100644 --- a/src/arduino/localWebServer.ts +++ b/src/arduino/localWebServer.ts @@ -5,6 +5,7 @@ import * as bodyParser from "body-parser"; import * as express from "express"; import * as http from "http"; import * as path from "path"; +import { Uri } from "vscode"; export default class LocalWebServer { private app = express(); @@ -19,8 +20,9 @@ export default class LocalWebServer { public getServerUrl(): string { return `http://localhost:${this.server.address().port}`; } - public getEndpointUri(type: string): string { - return `http://localhost:${this.server.address().port}/${type}`; + + public getEndpointUri(type: string): Uri { + return Uri.parse(`http://localhost:${this.server.address().port}/${type}`); } public addHandler(url: string, handler: (req, res) => void): void {