forked from node-red/node-red-node-swagger
-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
Problem
When Node-RED is deployed behind a reverse proxy with a subpath (e.g., /<NODERED-URL>/), the Swagger UI fails to load the OpenAPI specification because it uses a hardcoded absolute path.
Current behavior:
- Swagger UI is accessed at:
/<NODERED-URL>/swagger-ui/swagger-ui.html - It requests:
/http-api/swagger.json(absolute path) - This results in a 404 error because the endpoint is actually at
/<NODERED-URL>/http-api/swagger.json
Solution
Change the swagger.json URL from absolute to relative path:
- url: "/http-api/swagger.json",
+ url: "../http-api/swagger.json",
Why this works
- Without proxy: Resolves to /http-api/swagger.json ✓
- Behind proxy: Resolves to /nodered-server/http-api/swagger.json ✓
This is a non-breaking change that makes the library compatible with standard reverse proxy deployments (nginx, Apache, etc.) while maintaining existing functionality.
Testing
Tested with Node-RED behind Apache reverse proxy with ProxyPass /<NODERED-URL>/ http://nodered:1880/I did something like this which resolves the issue:
@digital-tvilling+node-red-openapi-generator+1.1.1.patch - file:
diff --git a/node_modules/@digital-tvilling/node-red-openapi-generator/swagger/swagger-ui/swagger-ui.html b/node_modules/@digital-tvilling/node-red-openapi-generator/swagger/swagger-ui/swagger-ui.html
index 1f10733..69d6654 100644
--- a/node_modules/@digital-tvilling/node-red-openapi-generator/swagger/swagger-ui/swagger-ui.html
+++ b/node_modules/@digital-tvilling/node-red-openapi-generator/swagger/swagger-ui/swagger-ui.html
@@ -13,7 +13,7 @@
<script>
window.onload = function() {
const ui = SwaggerUIBundle({
- url: "/http-api/swagger.json",
+ url: "../http-api/swagger.json",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels