From 2ae6f9d7de325b3f6d7d40b0ebaf440302cddb72 Mon Sep 17 00:00:00 2001 From: Alexander Borg Date: Sat, 6 Sep 2025 15:24:29 +0200 Subject: [PATCH] Fix jwt-token --- client/.env.development | 2 ++ client/.env.example | 8 +++++--- client/.env.production | 2 ++ client/src/config/app.js | 7 +++---- client/vite.config.js | 7 +++---- 5 files changed, 15 insertions(+), 11 deletions(-) create mode 100644 client/.env.development create mode 100644 client/.env.production diff --git a/client/.env.development b/client/.env.development new file mode 100644 index 0000000..033b42e --- /dev/null +++ b/client/.env.development @@ -0,0 +1,2 @@ +# Development environment - runs on root path +VITE_BASE_PATH= diff --git a/client/.env.example b/client/.env.example index 2e947e9..19af9ac 100644 --- a/client/.env.example +++ b/client/.env.example @@ -1,9 +1,11 @@ # Client Environment Configuration # Base path for the application (used for deployment in subdirectories) -# Default: '/drones' in production, '' in development -# Example: VITE_BASE_PATH=/my-custom-path -# VITE_BASE_PATH= +# Examples: +# For root deployment: VITE_BASE_PATH=/ +# For subdirectory deployment: VITE_BASE_PATH=/uggla/ +# Leave empty for default (root): VITE_BASE_PATH= +VITE_BASE_PATH=/uggla/ # API URL override (if API is hosted on different domain/port) # Default: auto-detected based on environment diff --git a/client/.env.production b/client/.env.production new file mode 100644 index 0000000..2cee3fe --- /dev/null +++ b/client/.env.production @@ -0,0 +1,2 @@ +# Production environment - deployed under /uggla/ path +VITE_BASE_PATH=/uggla/ diff --git a/client/src/config/app.js b/client/src/config/app.js index 89399fb..b18e9a1 100644 --- a/client/src/config/app.js +++ b/client/src/config/app.js @@ -1,8 +1,7 @@ -// Application configuration +// Application configuration from environment variables export const APP_CONFIG = { - // Base path for the application in production - // Can be overridden with VITE_BASE_PATH environment variable - basePath: import.meta.env.VITE_BASE_PATH || (import.meta.env.PROD ? '/drones' : ''), + // Base path for the application (set via VITE_BASE_PATH) + basePath: import.meta.env.VITE_BASE_PATH || '', // API configuration api: { diff --git a/client/vite.config.js b/client/vite.config.js index e2f8ef0..411fb54 100644 --- a/client/vite.config.js +++ b/client/vite.config.js @@ -1,10 +1,9 @@ import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' -// Application base path configuration -// Can be overridden with VITE_BASE_PATH environment variable -// This should match the base path used in nginx/reverse proxy configuration -const BASE_PATH = process.env.VITE_BASE_PATH || (process.env.NODE_ENV === 'production' ? '/drones/' : '/') +// Application base path configuration from environment variables +// Set VITE_BASE_PATH in .env files to configure the deployment path +const BASE_PATH = process.env.VITE_BASE_PATH || '/' export default defineConfig({ plugins: [react()],