From 240444abda8ac62212a5823d5da4606bc0a7a800 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Mon, 14 May 2018 13:18:35 +0100 Subject: [PATCH] Created Design: Custom Node admin route handling (markdown) --- Design:-Custom-Node-admin-route-handling.md | 31 +++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Design:-Custom-Node-admin-route-handling.md diff --git a/Design:-Custom-Node-admin-route-handling.md b/Design:-Custom-Node-admin-route-handling.md new file mode 100644 index 0000000..3c1deeb --- /dev/null +++ b/Design:-Custom-Node-admin-route-handling.md @@ -0,0 +1,31 @@ +Nodes are able to add their own custom routes to the `RED.httpAdmin` express app. This allows them to: + + - provide their own admin routes - such as the Serial node's ability to query active ports on the host + - serve up additional content - such as Debug loading its shared .js library and node-red-node-geofence loading the leaflet.js library and associated resources. + +Within the editor, as long as their reference those routes with a relative url, they will work regardless of what `httpAdminRoot` is set to. + +This poses some problems for the split of the editor and runtime. + +One of the goals of the split is to be able to serve the editor from a static file server (eg AWS S3) and point it at a server hosting the admin api. At this point, any relative urls a custom node uses will break - as they will be relative to the S3 url, not the admin api url. + +There are a number of ways a user may access these custom routes - each needs a slightly different solution. + +| Type of route | Resolution | +| ------------- | ------------- | +| `$.ajax` call | We already use `$.ajaxSetup()` to attach access tokens to relative urls. That can be updated to rewrite urls | +| **Adding scripts to the page** | | +| `$.getScript` | Also covered by `$.ajaxSetup()` fix | +| `