diff --git a/libs/api/index.ts b/libs/api/index.ts index 9e5cd1678..53572a128 100644 --- a/libs/api/index.ts +++ b/libs/api/index.ts @@ -25,6 +25,13 @@ export const api = new Api({ host: process.env.NODE_ENV === 'test' ? 'http://testhost' : '', }) +// add the API client to window for use from the browser JS console. requests +// will use the session cookie, same as normal API calls +if (typeof window !== 'undefined') { + // @ts-expect-error + window.oxide = api.methods +} + export type ApiMethods = typeof api.methods export const useApiQuery = getUseApiQuery(api.methods)