From 995fa8cdbd575af87b0ea494599bca4f5a9e15bc Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 17 Dec 2025 22:44:22 +0000 Subject: [PATCH] Add X-OpenPLC-Runtime-Version header to all API responses This adds an after_request hook to the REST API blueprint that includes the X-OpenPLC-Runtime-Version header with value 'v3' in all API responses. This enables the OpenPLC Editor to detect which runtime version it is connecting to and show an error if there is a version mismatch between the selected target and the actual runtime. Co-Authored-By: Thiago Alves --- webserver/restapi.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/webserver/restapi.py b/webserver/restapi.py index 097899f..fa46e43 100644 --- a/webserver/restapi.py +++ b/webserver/restapi.py @@ -28,6 +28,15 @@ logging.basicConfig( restapi_bp = Blueprint('restapi_blueprint', __name__) _handler_callback_get: Optional[Callable[[str, dict], dict]] = None _handler_callback_post: Optional[Callable[[str, dict], dict]] = None + + +@restapi_bp.after_request +def add_runtime_version_header(response): + """Add runtime version header to all API responses for version detection.""" + response.headers['X-OpenPLC-Runtime-Version'] = 'v3' + return response + + jwt = JWTManager(app_restapi) db = SQLAlchemy(app_restapi)