mirror of
https://github.com/plexguide/Huntarr.io.git
synced 2026-02-11 00:29:03 -06:00
Core Changes: - Add WSGI middleware to strip BASE_URL prefix before Flask routing - Centralize base URL logic with get_base_url_path() helper - Update environment variable to always override DB settings (Docker best practice) - Improve path checking to use startswith() instead of 'in' operator - Update all redirects to use centralized base URL helper Backend Updates: - web_server.py: Add BaseURLMiddleware class for proper subpath handling - auth.py: Add get_base_url_path() helper, update authenticate_request() path checks - routes/common.py: Simplify redirect logic using base URL helper - plex_auth_routes.py: Update Plex callback redirects - settings_manager.py: Environment variable now always overrides DB setting Frontend Updates: - cycle-countdown.js: Use window.HUNTARR_BASE_URL for API calls - Already has frontend injection in templates (index.html, login.html, etc.) Architecture: - WSGI middleware strips /huntarr from /huntarr/api/logs → Flask sees /api/logs - Industry-standard pattern for subpath deployments - No route modifications needed - middleware handles everything - Environment variable precedence follows Docker/k8s best practices Fixes: #649, #732 Related: #130 Testing: - Standard Docker deployment (no BASE_URL) - Docker with BASE_URL=/huntarr - BASE_URL changes via env var - All redirects and API calls Refinements over original PR: - Changed 'in' operator to startswith() for more precise path matching - Consistent base URL helper used throughout codebase - Simplified redirect logic (removed repetitive inline base URL logic)