solventum-image-metadata/src
SamoilenkoVadym 2ea4673bf0 Fix session persistence and improve AJAX detection for file uploads
Fixed three critical issues:

1. Session persistence - Cookies not saved after page refresh
   - Replaced APPLICATION_ROOT with SESSION_COOKIE_PATH
   - Added proper cookie settings for reverse proxy (HttpOnly, SameSite)
   - Set correct cookie path matching URL_PREFIX

2. AJAX detection for FormData uploads (JPG, etc.)
   - Enhanced @login_required to detect POST/PUT/DELETE as AJAX
   - Added Content-Type check for JSON requests
   - Added path prefix check for API endpoints

3. JavaScript AJAX identification
   - Updated fetchWithAuth() to add X-Requested-With header
   - Properly handles both JSON and FormData requests using Headers API
   - Ensures all fetch calls are identified as AJAX by server

Changes:
- web_app.py: Fixed Flask session cookie configuration
- src/auth.py: Improved AJAX detection logic in login_required decorator
- templates/index.html: Enhanced fetchWithAuth() with proper headers

This fixes:
- Users having to re-login on every page refresh
- "Unexpected token '<'" errors when uploading JPG files
- Session cookies not persisting through reverse proxy

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
2026-02-09 11:24:49 +00:00
..
extractors Phase 1.4: ExifTool integration for enhanced metadata support 2026-01-25 15:26:01 +00:00
updaters Phase 1.4: ExifTool integration for enhanced metadata support 2026-01-25 15:26:01 +00:00
__init__.py Initial commit: Universal metadata tool with Excel-based lookup 2026-01-25 14:23:42 +00:00
auth.py Fix session persistence and improve AJAX detection for file uploads 2026-02-09 11:24:49 +00:00
base_extractor.py Initial commit: Universal metadata tool with Excel-based lookup 2026-01-25 14:23:42 +00:00
base_updater.py Initial commit: Universal metadata tool with Excel-based lookup 2026-01-25 14:23:42 +00:00
config.py Phase 1.1: Rebrand to Oliver Metadata Tool v3.0 2026-01-25 15:15:26 +00:00
database.py Add deployment script and configure reverse proxy with Azure SSO 2026-02-06 16:37:19 +00:00
excel_metadata_lookup.py Initial commit: Universal metadata tool with Excel-based lookup 2026-01-25 14:23:42 +00:00
field_mapper.py Phase 3.1: Field mapping foundation with auto-detection 2026-01-25 15:45:11 +00:00
file_detector.py Initial commit: Universal metadata tool with Excel-based lookup 2026-01-25 14:23:42 +00:00
main.py Initial commit: Universal metadata tool with Excel-based lookup 2026-01-25 14:23:42 +00:00
metadata_analyzer.py Add GPT-5 model support with enhanced API logging 2026-01-26 14:33:55 +00:00
metadata_importer.py Phase 3.1: Field mapping foundation with auto-detection 2026-01-25 15:45:11 +00:00
template_manager.py Phase 3 Complete: Batch Selection, CSV Export, and Metadata Templates 2026-01-25 15:52:05 +00:00
utils.py Initial commit: Universal metadata tool with Excel-based lookup 2026-01-25 14:23:42 +00:00