I’m working with N8N embedded in an iframe and need to extract URL parameters inside a custom node I built. The application passes certain values through the URL that I need to access for automation tasks.
I’ve attempted several approaches but none seem to work properly:
Using window.location.href throws an error since the window object isn’t available
Tried the Node.js url module approach:
const urlModule = require('url');
let queryParams = new urlModule.URLSearchParams('param=example123');
console.log(queryParams.get('param'));
The issue with this second method is that I can’t figure out how to actually retrieve the current URL to pass into URLSearchParams. Has anyone successfully accessed URL parameters from within custom N8N nodes? What’s the proper way to get the current page URL in this context?
I ran into this same issue building custom N8N nodes. You can’t access browser stuff like the DOM since these nodes run in Node.js. Use N8N’s workflow parameters instead. Try this.getWorkflowStaticData() to grab static data passed to your workflow. If you’ve set up input parameters on your custom node, make sure they’re configured right to pull in those URL parameters. Way easier to pass the parameters from the previous workflow step than trying to fetch them inside the node itself.
Had the same issue building custom N8N nodes. Custom nodes run server-side, so you can’t access browser APIs at all. I solved it by extracting URL parameters at the workflow level before they reach the custom node. Set up a webhook trigger to grab the URL parameters and pass them as input data to your node. Or use an HTTP Request node to make a call with those parameters, then feed that data into your custom node. If you really need to work with URLs inside the node code, you’ll have to receive the full URL as input from an earlier workflow step - you can’t access it directly.
yup, this confuses many with n8n nodes. they run server-side, so window and document objects aren’t accessible. i solved it by using a webhook to catch the URL params first and then sending them as JSON to the custom node. also try this.getInputData() for params from earlier steps.