Make the client more secure (#3742)
Co-authored-by: Douwe Osinga <douwe@squareup.com> Co-authored-by: Michael Neale <michael.neale@gmail.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { clsx, type ClassValue } from 'clsx';
|
||||
import { twMerge } from 'tailwind-merge';
|
||||
import { client } from './api/client.gen';
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs));
|
||||
@@ -16,3 +17,19 @@ export function patchConsoleLogging() {
|
||||
// Intercept console methods
|
||||
return;
|
||||
}
|
||||
|
||||
// This needs to be called before any API calls are made, but since we're using the client
|
||||
// in multiple useEffect locations, we can't be sure who goes first.
|
||||
let clientInitialized = false;
|
||||
|
||||
export async function ensureClientInitialized() {
|
||||
if (clientInitialized) return;
|
||||
client.setConfig({
|
||||
baseUrl: window.appConfig.get('GOOSE_API_HOST') + ':' + window.appConfig.get('GOOSE_PORT'),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Secret-Key': await window.electron.getSecretKey(),
|
||||
},
|
||||
});
|
||||
clientInitialized = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user