diff --git a/core/util/index.ts b/core/util/index.ts index b03717430..523dea764 100644 --- a/core/util/index.ts +++ b/core/util/index.ts @@ -31,10 +31,13 @@ export function proxyFetch(url: string, init?: RequestInit): Promise { throw new Error("Proxy fetch not initialized"); } + const proxyServerUrl = + (window as any).proxyServerUrl || "http://localhost:65433"; + const headers = new Headers(init?.headers); headers.append("x-continue-url", url); - return (window as any)._fetch("http://localhost:65433", { + return (window as any)._fetch(proxyServerUrl, { ...init, headers, }); diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 798276b6d..98375c217 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -61,6 +61,11 @@ "type": "boolean", "default": true, "description": "Show inline suggestion to use the Continue keyboard shortcuts." + }, + "continue.proxyServerUrl": { + "type": "string", + "default": "http://localhost:65433", + "description": "An optional proxy server URL through which you can route all Continue requests. Do not change this unless you have set up your own server to proxy requests." } } }, diff --git a/extensions/vscode/src/activation/proxy.ts b/extensions/vscode/src/activation/proxy.ts index 7da27e0e4..fc87f5081 100644 --- a/extensions/vscode/src/activation/proxy.ts +++ b/extensions/vscode/src/activation/proxy.ts @@ -2,6 +2,7 @@ import cors from "cors"; import express from "express"; import http from "http"; import https from "https"; +import * as vscode from "vscode"; const PROXY_PORT = 65433; const app = express(); @@ -54,6 +55,16 @@ app.use((req, res, next) => { // }); export function startProxy() { + const proxyServerUrl = vscode.workspace + .getConfiguration("continue") + .get("proxyServerUrl"); + if ( + proxyServerUrl !== "http://localhost:65433" && + proxyServerUrl !== "http://127.0.0.1:65433" + ) { + return; + } + const server = app.listen(PROXY_PORT, () => { console.log(`Proxy server is running on port ${PROXY_PORT}`); }); diff --git a/extensions/vscode/src/debugPanel.ts b/extensions/vscode/src/debugPanel.ts index 1bd06e6d0..aac31220e 100644 --- a/extensions/vscode/src/debugPanel.ts +++ b/extensions/vscode/src/debugPanel.ts @@ -461,6 +461,9 @@ export function getSidebarContent( ) || [] )} + ${ edits