Define API base in config
Add src/config.ts with API baseUrl defaulting to environment var VITE_API_BASE_URL or '/api/v1'. Wire api.ts to use config.api.baseUrl instead of hardcoded base. X-Lovable-Edit-ID: edt-474d2059-e9f4-4467-8d13-d089d07abac8
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
// Gatehouse Configuration
|
||||||
|
// Environment-specific settings for the application
|
||||||
|
|
||||||
|
export const config = {
|
||||||
|
// API Configuration
|
||||||
|
api: {
|
||||||
|
baseUrl: import.meta.env.VITE_API_BASE_URL || '/api/v1',
|
||||||
|
},
|
||||||
|
|
||||||
|
// App metadata
|
||||||
|
app: {
|
||||||
|
name: 'Gatehouse',
|
||||||
|
description: 'Identity & Access Platform',
|
||||||
|
},
|
||||||
|
|
||||||
|
// Feature flags
|
||||||
|
features: {
|
||||||
|
devTools: import.meta.env.DEV,
|
||||||
|
},
|
||||||
|
} as const;
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
// API Client for Gatehouse Backend
|
// API Client for Gatehouse Backend
|
||||||
// Uses session-based authentication with cookies
|
// Uses session-based authentication with cookies
|
||||||
|
|
||||||
const API_BASE = '/api/v1';
|
import { config } from '@/config';
|
||||||
|
|
||||||
interface ApiResponse<T = unknown> {
|
interface ApiResponse<T = unknown> {
|
||||||
version: string;
|
version: string;
|
||||||
@@ -58,7 +58,7 @@ async function request<T>(
|
|||||||
endpoint: string,
|
endpoint: string,
|
||||||
options: RequestInit = {}
|
options: RequestInit = {}
|
||||||
): Promise<T> {
|
): Promise<T> {
|
||||||
const response = await fetch(`${API_BASE}${endpoint}`, {
|
const response = await fetch(`${config.api.baseUrl}${endpoint}`, {
|
||||||
...options,
|
...options,
|
||||||
credentials: 'include', // Important: include session cookies
|
credentials: 'include', // Important: include session cookies
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
Reference in New Issue
Block a user