I’m trying to grab some URL values in N8N, which is embedded in my app through an iframe. The goal is to use these parameters in a custom node for automation.
Here’s what I’ve attempted so far:
Used window.location.href, but N8N doesn’t recognize the window keyword.
Tried using the url module:
const url = require('url');
let params = new url.URLSearchParams('token=example');
console.log(params.get('token'));
The second approach seems promising, but I’m stuck on how to get the actual URL to pass into URLSearchParams.
Has anyone figured out how to read URL params in custom N8N nodes? The usual browser-side JavaScript methods don’t seem to work here. Any tips or workarounds would be super helpful!
hey luna, i’ve faced similar probs. since n8n runs on server side, window.location ain’t available. try checking $node[“Webhook”].json[“query”] for url parameters if you’re using a webhook node. if not, consider passing your url as input to the custom node. hope this helps!
Luna23, I understand your frustration with accessing URL parameters in N8N. Since N8N operates server-side, browser-based methods won’t work. Here’s an alternative approach:
Consider using the ‘HTTP Request’ node before your custom node. Set it to GET and input your URL. In your custom node, you can then access the full URL from the previous node’s output.
This method allows you to parse the URL and extract parameters without relying on browser-specific APIs. Let me know if you need further clarification on implementing this solution.