mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-06 08:21:50 +00:00
fix(desktop): respect proxy environment (#25846)
This commit is contained in:
parent
bb9b81aa37
commit
465c83cf82
2 changed files with 17 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { randomUUID } from "node:crypto"
|
||||
import { EventEmitter } from "node:events"
|
||||
import { existsSync } from "node:fs"
|
||||
import * as http from "node:http"
|
||||
import { createServer } from "node:net"
|
||||
import { homedir } from "node:os"
|
||||
import { join } from "node:path"
|
||||
|
|
@ -77,6 +78,7 @@ setupApp()
|
|||
|
||||
function setupApp() {
|
||||
ensureLoopbackNoProxy()
|
||||
useEnvProxy()
|
||||
app.commandLine.appendSwitch("proxy-bypass-list", "<-loopback>")
|
||||
if (!app.isPackaged) app.commandLine.appendSwitch("remote-debugging-port", "9222")
|
||||
|
||||
|
|
@ -133,6 +135,15 @@ function useSystemCertificates() {
|
|||
}
|
||||
}
|
||||
|
||||
function useEnvProxy() {
|
||||
try {
|
||||
// Electron 41.2 runs Node 24.14.1; latest @types/node@24 is 24.12.2.
|
||||
;(http as any).setGlobalProxyFromEnv()
|
||||
} catch (error) {
|
||||
logger.warn("failed to load proxy environment", error)
|
||||
}
|
||||
}
|
||||
|
||||
function emitDeepLinks(urls: string[]) {
|
||||
if (urls.length === 0) return
|
||||
pendingDeepLinks.push(...urls)
|
||||
|
|
@ -189,7 +200,10 @@ async function initialize() {
|
|||
}
|
||||
|
||||
logger.log("spawning sidecar", { url })
|
||||
const { listener, health } = await spawnLocalServer(hostname, port, password)
|
||||
const { listener, health } = await spawnLocalServer(hostname, port, password, () => {
|
||||
ensureLoopbackNoProxy()
|
||||
useEnvProxy()
|
||||
})
|
||||
server = listener
|
||||
serverReady.resolve({
|
||||
url,
|
||||
|
|
|
|||
|
|
@ -30,8 +30,9 @@ export function setWslConfig(config: WslConfig) {
|
|||
getStore().set(WSL_ENABLED_KEY, config.enabled)
|
||||
}
|
||||
|
||||
export async function spawnLocalServer(hostname: string, port: number, password: string) {
|
||||
export async function spawnLocalServer(hostname: string, port: number, password: string, configureEnv?: () => void) {
|
||||
prepareServerEnv(password)
|
||||
configureEnv?.()
|
||||
const { Log, Server } = await import("virtual:opencode-server")
|
||||
await Log.init({ level: "WARN" })
|
||||
const listener = await Server.listen({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue