fix gui client initialization when using an external backend (#4669)

Signed-off-by: Ignasi Barrera <nacx@apache.org>
This commit is contained in:
Ignasi Barrera
2025-09-20 05:15:25 +02:00
committed by GitHub
parent 88dd9cbeea
commit 6e7ec1974b
3 changed files with 35 additions and 3 deletions
+12 -2
View File
@@ -47,10 +47,20 @@ const checkServerStatus = async (): Promise<boolean> => {
const connectToExternalBackend = async (
workingDir: string,
port: number = 3000
port: number = 3000,
serverSecret: string
): Promise<[number, string, ChildProcess]> => {
log.info(`Using external goosed backend on port ${port}`);
// Configure the client BEFORE checking server status
client.setConfig({
baseUrl: `http://127.0.0.1:${port}`,
headers: {
'Content-Type': 'application/json',
'X-Secret-Key': serverSecret,
},
});
const isReady = await checkServerStatus();
if (!isReady) {
throw new Error(`External goosed server not accessible on port ${port}`);
@@ -94,7 +104,7 @@ export const startGoosed = async (
dir = path.resolve(path.normalize(dir));
if (process.env.GOOSE_EXTERNAL_BACKEND) {
return connectToExternalBackend(dir, 3000);
return connectToExternalBackend(dir, 3000, serverSecret);
}
// Validate that the directory actually exists and is a directory