Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions ui/desktop/src/goosed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 client for external backend before checking 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}`);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of duplicating this code, we can jsut delete the isReady check since that happens after we call this function anyway

Expand Down Expand Up @@ -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
Expand Down
Loading