diff --git a/src/backend/services/runtimeConfig.ts b/src/backend/services/runtimeConfig.ts index 37e23db..e0be560 100644 --- a/src/backend/services/runtimeConfig.ts +++ b/src/backend/services/runtimeConfig.ts @@ -32,7 +32,7 @@ export function generateRuntimeConfig( // Generate env.js content const envConfig = { - basePath: basePath || '/', + BASE_PATH: basePath || '/', FRONTEND_API_KEY: config.apiKeys.frontend, }; diff --git a/src/frontend/public/env.js b/src/frontend/public/env.js index d57ec5d..e2501bb 100644 --- a/src/frontend/public/env.js +++ b/src/frontend/public/env.js @@ -2,5 +2,6 @@ // DO NOT EDIT - This file is automatically generated // eslint-disable-next-line no-undef window.env = { - "basePath": "/" + "BASE_PATH": "/", + "FRONTEND_API_KEY": "frontend-dev-key" }; diff --git a/src/frontend/src/main.tsx b/src/frontend/src/main.tsx index 962f293..5146b18 100644 --- a/src/frontend/src/main.tsx +++ b/src/frontend/src/main.tsx @@ -3,17 +3,7 @@ import ReactDOM from 'react-dom/client'; import { BrowserRouter } from 'react-router-dom'; import App from './App.tsx'; -// Runtime config loaded from env.js (generated by backend at startup) -declare global { - interface Window { - env?: { - basePath?: string; - FRONTEND_API_KEY: string; - }; - } -} - -const basename = window.env?.basePath || '/'; +const basename = window.env.BASE_PATH || '/'; ReactDOM.createRoot(document.getElementById('root')!).render( diff --git a/src/frontend/src/types/globals.d.ts b/src/frontend/src/types/globals.d.ts new file mode 100644 index 0000000..374e990 --- /dev/null +++ b/src/frontend/src/types/globals.d.ts @@ -0,0 +1,20 @@ +/** + * Global type declarations for the Bitip frontend application + * This file contains ambient declarations for global objects and runtime configuration + */ + +/** + * Runtime configuration loaded from env.js + * Generated by backend at startup and injected into window object + */ +declare global { + interface Window { + env: { + BASE_PATH: string; + FRONTEND_API_KEY: string; + }; + } +} + +// This export makes this file a module, which is required for global augmentation +export {};