From 7993b5f4e83c6c75a85a634ca42b3ff8a5d1d0a9 Mon Sep 17 00:00:00 2001 From: Kevin Date: Wed, 2 Jul 2025 11:41:29 -0500 Subject: [PATCH] fix: env to helper function api base url --- src/lib/desktop.ts | 8 +++----- src/machines/authMachine.ts | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/lib/desktop.ts b/src/lib/desktop.ts index f290d353a..cecba01a8 100644 --- a/src/lib/desktop.ts +++ b/src/lib/desktop.ts @@ -26,6 +26,7 @@ import { err } from '@src/lib/trap' import type { DeepPartial } from '@src/lib/types' import { getInVariableCase } from '@src/lib/utils' import { IS_STAGING } from '@src/routes/utils' +import { withAPIBaseURL } from '@src/lib/withBaseURL' export async function renameProjectDirectory( projectPath: string, @@ -724,12 +725,9 @@ export const setState = async (state: Project | undefined): Promise => { appStateStore = state } -export const getUser = async ( - token: string, - hostname: string -): Promise => { +export const getUser = async (token: string): Promise => { try { - const user = await fetch(`${hostname}/users/me`, { + const user = await fetch(withAPIBaseURL('/users/me'), { headers: new Headers({ Authorization: `Bearer ${token}`, }), diff --git a/src/machines/authMachine.ts b/src/machines/authMachine.ts index 84698b033..ed87ffad4 100644 --- a/src/machines/authMachine.ts +++ b/src/machines/authMachine.ts @@ -1,5 +1,5 @@ import type { Models } from '@kittycad/lib' -import { VITE_KC_API_BASE_URL, VITE_KC_DEV_TOKEN } from '@src/env' +import { VITE_KC_DEV_TOKEN } from '@src/env' import { assign, fromPromise, setup } from 'xstate' import { COOKIE_NAME, OAUTH2_DEVICE_CLIENT_ID } from '@src/lib/constants' @@ -148,7 +148,7 @@ async function getUser(input: { token?: string }) { if (token) headers['Authorization'] = `Bearer ${token}` const userPromise = isDesktop() - ? getUserDesktop(token, VITE_KC_API_BASE_URL) + ? getUserDesktop(token) : fetch(url, { method: 'GET', credentials: 'include',