✨ add proxyServerUrl setting

This commit is contained in:
Nate Sesti 2023-12-14 21:33:51 -08:00
parent 02d3147023
commit 67d939b80a
4 changed files with 23 additions and 1 deletions

View file

@ -31,10 +31,13 @@ export function proxyFetch(url: string, init?: RequestInit): Promise<Response> {
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,
});

View file

@ -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."
}
}
},

View file

@ -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}`);
});

View file

@ -461,6 +461,9 @@ export function getSidebarContent(
) || []
)}</script>
<script>window.isFullScreen = ${isFullScreen}</script>
<script>window.proxyServerUrl = "${vscode.workspace
.getConfiguration("continue")
.get("proxyServerUrl")}"</script>
${
edits