Skip to content

Conversation

@aviborg
Copy link

@aviborg aviborg commented Jan 19, 2026

Summary

I have refactored the codebase to use relative paths, which allows the application to be deployed in any subfolder (e.g., example.com/opentakserver/)

THE BACKEND HAS NOT BEEN TESTED OR FIXED AGAINST THIS CHANGE YET !!!

Key Changes Made:

  • Vite Configuration: Updated vite.config.mjs to set base: './'. This ensures that all bundled assets (JS, CSS, etc.) are linked using relative paths.
  • Relative Asset Links: Modified index.html to remove leading slashes from manually linked assets like the favicon, web manifest, and the main entry script.
  • Relative API Routes: Updated src/apiRoutes.tsx to remove leading slashes from all API endpoints. This makes them relative to the folder where the UI is served.
  • Localization & Assets: Updated src/i18n.js (translation files) and src/DefaultLayout.tsx to use relative paths.
  • Map Icons: Modified src/pages/Map/Map.tsx to ensure default Leaflet marker icons are loaded relatively.
  • HashRouter Implementation: I switched the application from BrowserRouter to HashRouter in src/App.tsx. Why? This is the most robust way to support subfolder deployments without requiring any server-side configuration (like Nginx try_files or .env variables). All SPA routing is now handled after the # in the URL, making the app completely agnostic to its parent folder depth.

Summary of modified files:

  • vite.config.mjs: Added base: './'
  • index.html: Removed leading slashes from all and <script> tags.
  • src/apiRoutes.tsx: Removed leading slashes from all 60+ API endpoints.
  • src/i18n.js: Updated loadPath to be relative.
  • src/DefaultLayout.tsx:: Updated alert.mp3 path.
  • src/pages/Map/Map.tsx: Updated Leaflet icon paths.
  • public/site.webmanifest: Updated internal icon paths.
  • src/App.tsx: Replaced BrowserRouter with HashRouter.

The application should now load correctly at example.com/opentakserver/ (or any other path) by simply pointing your document root to the appropriate folder.

Fixes #163

…i18n, with Vite configured for relative asset paths.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use relative paths for assets and more

1 participant