Hi yall, Ive been using n8n for a while now and today I wanted to use the URLURL() - Web APIs | MDN interface inside a function node but ran into an error.
ReferenceError: URL is not defined
at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/FunctionItem:5:13
at /usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/FunctionItem:16:2
at BaseHandler.apply (/usr/local/lib/node_modules/n8n/node_modules/vm2/lib/bridge.js:479:11)
at NodeVM.run (/usr/local/lib/node_modules/n8n/node_modules/vm2/lib/nodevm.js:425:23)
at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/FunctionItem/FunctionItem.node.js:106:41)
at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/src/Workflow.js:526:37)
at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/src/WorkflowExecute.js:451:62
Does anybody know why the URL interface is not accessible? I’m using the n8n cloud version and just checked the node version, which is 16.14. According to mdn the URL interface is available since node 10…
Please share the workflow
Information on your n8n setup
n8n version: 0.166.0
Database you’re using (default: SQLite): don’t know, hosted version
Running n8n with the execution process [own(default), main]: don’t know what you mean
Running n8n via [Docker, npm, n8n.cloud, desktop app]: n8n.cloud
As I already described, I’m trying to use the URL interface inside a function node, but it isn’t available and I’m wondering why that is the case. Sure, I could work around it, but I want to know why I can’t access use the URL interface, especially given that it usually is provided with the node version that n8n is running on, 16.14.0.
And I don’t quite understand how the HTTP node could be of use for my problem, please enlighten me
It also fails on self hosted installs as the default option we use is to disable built in modules, For self hosted installs NODE_FUNCTION_ALLOW_BUILTIN would need to be set but for Cloud things are a bit different.
I see, thanks for your insights. Do you know if there is any way to get access to builtin modules in the cloud version? Switching to selfhosted sadly isn’t an option for me
That is a good question it all depends on the Cloud team, I am not sure what the exact rules are for Cloud and built in modules but @MutedJam will have more of an idea on that one
Seems you need to require it first on Node.js, but for n8n that would mean you’d first need to specifically allow it via the respective NODE_FUNCTION_ALLOW_BUILTINenvironment variable.
Unfortunately, it’s not possible to manually configure your own environment on n8n.cloud, so I shall convert this into a feature request allowing you and other users to vote on it. From what I remember even though this is a small change it took quite a while to allow a module for all cloud users the last time such a request came up unfortunately (it was momentjs back then).
So if you have working regex that would definitely make things easier on n8n.cloud.
Edit: In case someone is self-hosting n8n and stumbles across this thread, NODE_FUNCTION_ALLOW_BUILTIN=url would indeed do the trick. Just tested this syntax in my Function node: