Hello,
I’m trying to fetch only a specific flow based on the flow ID from the URL in Node-RED's editor (e.g., http://localhost:4200/editor/#flow/5d4ed2fee1e3ecb0
) instead of fetching all flows.
Currently, I’m using an httpAdminMiddleware
to intercept the request, but I’m unable to retrieve the flow ID from the URL in the request. It seems like Node-RED is directly making an API call to fetch all flows, and I don't see the flow ID in the request headers or body.
Here’s the code for my current approach:
javascript
Copy code
const flowId = 'a3994a4a93d6a53e';
export async function interceptFlowRequests(req, res, next) {
if (req.method === 'GET' && req.url.startsWith('/flows')) {
console.log('URL:', req.url);
const originalJson = res.json;
res.json = function(data) {
const filteredData = data.flows.filter(item => item.id === flowId || item.z === flowId);
return originalJson.apply(res, [{ flows: filteredData }]);
};
}
next();
}
I’ve hardcoded the flow ID for testing, but I’d like to dynamically retrieve the flow ID based on the URL in the editor (e.g., extracting it from #flow/<flowId>
).
If anyone could offer any guidance on how to get the flow ID from the URL in the request or suggest a better approach to achieve this, it would be greatly appreciated!
Thank you in advance for your help!