diff --git a/Dockerfile b/Dockerfile index 57a7c646..ebc14728 100644 --- a/Dockerfile +++ b/Dockerfile @@ -110,7 +110,7 @@ EXPOSE ${FLASK_PORT} # Add healthcheck for container status # This will run as root initially, but check localhost which should work if the app binds correctly. HEALTHCHECK --interval=60s --timeout=60s --start-period=60s --retries=3 \ - CMD curl -s http://localhost:${FLASK_PORT}/request/api/status > /dev/null || exit 1 + CMD curl -s http://localhost:${FLASK_PORT}/api/status > /dev/null || exit 1 # Use dumb-init as the entrypoint to handle signals properly ENTRYPOINT ["/usr/bin/dumb-init", "--"] diff --git a/app.py b/app.py index 1600e01c..3b2414d1 100644 --- a/app.py +++ b/app.py @@ -12,7 +12,6 @@ from flask_socketio import SocketIO, emit from werkzeug.middleware.proxy_fix import ProxyFix from werkzeug.security import check_password_hash from werkzeug.wrappers import Response -from flask import url_for as flask_url_for import typing from logger import setup_logger @@ -132,10 +131,10 @@ if DEBUG: class StatusEndpointFilter(logging.Filter): """Filter out routine status endpoint requests to reduce log noise.""" def filter(self, record): - # Exclude GET /api/status and GET /request/api/status requests + # Exclude GET /api/status requests if hasattr(record, 'getMessage'): message = record.getMessage() - if 'GET /api/status' in message or 'GET /request/api/status' in message: + if 'GET /api/status' in message: return False return True @@ -194,44 +193,6 @@ def login_required(f): return f(*args, **kwargs) return decorated_function -def register_dual_routes(app : Flask) -> None: - """ - Register each route both with and without the /request prefix. - This function should be called after all routes are defined. - """ - # Store original url_map rules - rules = list(app.url_map.iter_rules()) - - # Add /request prefix to each rule - for rule in rules: - if rule.rule != '/request/' and rule.rule != '/request': # Skip if it's already a request route - # Create new routes with /request prefix, both with and without trailing slash - base_rule = rule.rule[:-1] if rule.rule.endswith('/') else rule.rule - if base_rule == '': # Special case for root path - app.add_url_rule('/request', f"root_request", - view_func=app.view_functions[rule.endpoint], - methods=rule.methods) - app.add_url_rule('/request/', f"root_request_slash", - view_func=app.view_functions[rule.endpoint], - methods=rule.methods) - else: - app.add_url_rule(f"/request{base_rule}", - f"{rule.endpoint}_request", - view_func=app.view_functions[rule.endpoint], - methods=rule.methods) - app.add_url_rule(f"/request{base_rule}/", - f"{rule.endpoint}_request_slash", - view_func=app.view_functions[rule.endpoint], - methods=rule.methods) - app.jinja_env.globals['url_for'] = url_for_with_request - -def url_for_with_request(endpoint : str, **values : typing.Any) -> str: - """Generate URLs with /request prefix by default.""" - if endpoint == 'static' or endpoint == 'serve_frontend_assets': - # For static files, add /request prefix - url = flask_url_for(endpoint, **values) - return f"/request{url}" - return flask_url_for(endpoint, **values) # Serve frontend static files @app.route('/assets/') @@ -259,8 +220,6 @@ def logo() -> Response: @app.route('/favicon.ico') @app.route('/favico') -@app.route('/request/favico') -@app.route('/request/static/favico') def favicon(_ : typing.Any = None) -> Response: """ Serve favicon from built frontend assets. @@ -823,9 +782,6 @@ def catch_all(path: str) -> Response: # Otherwise serve the React app return send_from_directory(os.path.join(app.root_path, 'frontend-dist'), 'index.html') -# Register all routes with /request prefix -register_dual_routes(app) - # WebSocket event handlers @socketio.on('connect') def handle_connect(): diff --git a/readme.md b/readme.md index d1f293b0..dd5d4f4f 100644 --- a/readme.md +++ b/readme.md @@ -275,7 +275,7 @@ Checks run every 30 seconds with a 30-second timeout and 3 retries. You can enable by adding this to your compose : ``` HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ - CMD pyrequests http://localhost:8084/request/api/status || exit 1 + CMD curl -s http://localhost:8084/api/status || exit 1 ``` ## 📝 Logging diff --git a/src/README.md b/src/README.md index b02db798..85a971d1 100644 --- a/src/README.md +++ b/src/README.md @@ -69,8 +69,8 @@ The development server supports HMR for instant feedback during development. ### API Integration The frontend communicates with the Flask backend via: -- REST API endpoints (`/request/api/*`) -- WebSocket connection (`ws://localhost:8084/request/ws`) +- REST API endpoints (`/api/*`) +- WebSocket connection (`ws://localhost:8084/ws`) ### Building for Production The production build is optimized and minified: diff --git a/src/frontend/src/components/DownloadsSidebar.tsx b/src/frontend/src/components/DownloadsSidebar.tsx index 34319f93..c4708742 100644 --- a/src/frontend/src/components/DownloadsSidebar.tsx +++ b/src/frontend/src/components/DownloadsSidebar.tsx @@ -192,7 +192,7 @@ export const DownloadsSidebar = ({

{isCompleted && book.download_path ? ( {book.title || 'Unknown Title'} diff --git a/src/frontend/src/components/Header.tsx b/src/frontend/src/components/Header.tsx index 078d45c5..fe721b36 100644 --- a/src/frontend/src/components/Header.tsx +++ b/src/frontend/src/components/Header.tsx @@ -277,7 +277,7 @@ export const Header = ({ {/* Debug Buttons */} {debug && ( <> -
+
-
+