diff --git a/src/lib/coredump.ts b/src/lib/coredump.ts index bb88a8637..40040871f 100644 --- a/src/lib/coredump.ts +++ b/src/lib/coredump.ts @@ -1,4 +1,3 @@ -import { VITE_KC_API_BASE_URL } from '@src/env' import { UAParser } from 'ua-parser-js' import type { OsInfo } from '@rust/kcl-lib/bindings/OsInfo' @@ -11,6 +10,7 @@ import { isDesktop } from '@src/lib/isDesktop' import type RustContext from '@src/lib/rustContext' import screenshot from '@src/lib/screenshot' import { APP_VERSION } from '@src/routes/utils' +import { withAPIBaseURL } from '@src/lib/withBaseURL' /* eslint-disable suggest-no-throw/suggest-no-throw -- * All the throws in CoreDumpManager are intentional and should be caught and handled properly @@ -35,7 +35,7 @@ export class CoreDumpManager { codeManager: CodeManager rustContext: RustContext token: string | undefined - baseUrl: string = VITE_KC_API_BASE_URL + baseUrl: string = withAPIBaseURL('') constructor( engineCommandManager: EngineCommandManager, diff --git a/src/lib/promptToEdit.tsx b/src/lib/promptToEdit.tsx index 8c3ba5289..428bd5162 100644 --- a/src/lib/promptToEdit.tsx +++ b/src/lib/promptToEdit.tsx @@ -1,7 +1,7 @@ import type { SelectionRange } from '@codemirror/state' import { EditorSelection, Transaction } from '@codemirror/state' import type { Models } from '@kittycad/lib' -import { VITE_KC_API_BASE_URL, VITE_KC_SITE_BASE_URL } from '@src/env' +import { VITE_KC_SITE_BASE_URL } from '@src/env' import { diffLines } from 'diff' import toast from 'react-hot-toast' import type { TextToCadMultiFileIteration_type } from '@kittycad/lib/dist/types/src/models' diff --git a/src/lib/singletons.ts b/src/lib/singletons.ts index 8eb57da67..5202ed83c 100644 --- a/src/lib/singletons.ts +++ b/src/lib/singletons.ts @@ -1,4 +1,4 @@ -import { VITE_KC_API_BASE_URL } from '@src/env' +import { withAPIBaseURL } from '@src/lib/withBaseURL' import EditorManager from '@src/editor/manager' import { KclManager } from '@src/lang/KclSingleton' @@ -171,7 +171,7 @@ const appMachine = setup({ systemId: BILLING, input: { ...BILLING_CONTEXT_DEFAULTS, - urlUserService: VITE_KC_API_BASE_URL, + urlUserService: withAPIBaseURL(''), }, }), ], diff --git a/src/lib/textToCad.ts b/src/lib/textToCad.ts index 7e9f5f4dc..01b0677dc 100644 --- a/src/lib/textToCad.ts +++ b/src/lib/textToCad.ts @@ -1,5 +1,4 @@ import type { Models } from '@kittycad/lib' -import { VITE_KC_API_BASE_URL } from '@src/env' import toast from 'react-hot-toast' import type { NavigateFunction } from 'react-router-dom' import { @@ -19,6 +18,7 @@ import { err, reportRejection } from '@src/lib/trap' import { toSync } from '@src/lib/utils' import { getAllSubDirectoriesAtProjectRoot } from '@src/machines/systemIO/snapshotContext' import { joinOSPaths } from '@src/lib/paths' +import { withAPIBaseURL } from '@src/lib/withBaseURL' export async function submitTextToCadPrompt( prompt: string, @@ -32,7 +32,7 @@ export async function submitTextToCadPrompt( kcl_version: kclManager.kclVersion, } // Glb has a smaller footprint than gltf, should we want to render it. - const url = VITE_KC_API_BASE_URL + '/ai/text-to-cad/glb?kcl=true' + const url = withAPIBaseURL('/ai/text-to-cad/glb?kcl=true') const data: Models['TextToCad_type'] | Error = await crossPlatformFetch( url, { @@ -58,7 +58,7 @@ export async function getTextToCadResult( id: string, token?: string ): Promise { - const url = VITE_KC_API_BASE_URL + '/user/text-to-cad/' + id + const url = withAPIBaseURL(`/user/text-to-cad/${id}`) const data: Models['TextToCad_type'] | Error = await crossPlatformFetch( url, { diff --git a/src/lib/textToCadTelemetry.ts b/src/lib/textToCadTelemetry.ts index a5c336522..33246e756 100644 --- a/src/lib/textToCadTelemetry.ts +++ b/src/lib/textToCadTelemetry.ts @@ -1,14 +1,13 @@ import type { Models } from '@kittycad/lib/dist/types/src' -import { VITE_KC_API_BASE_URL } from '@src/env' import crossPlatformFetch from '@src/lib/crossPlatformFetch' +import { withAPIBaseURL } from '@src/lib/withBaseURL' export async function sendTelemetry( id: string, feedback: Models['MlFeedback_type'], token?: string ): Promise { - const url = - VITE_KC_API_BASE_URL + '/user/text-to-cad/' + id + '?feedback=' + feedback + const url = withAPIBaseURL(`/user/text-to-cad/${id}/?feedback=${feedback}`) await crossPlatformFetch( url, {