Problem Description
I’m developing a custom node in N8N and struggling to retrieve URL parameters passed through an iframe-embedded application. My goal is to access these parameters programmatically for automation workflows.
Attempted Solutions
- Tried using
window.location.href, but encountered issues with browser-side JavaScript access
- Attempted URL parsing using Node.js
url module
- Manually constructed URLSearchParams with static token
Specific Challenges
- Cannot dynamically extract full URL within the custom node
- Unsure how to correctly parse and extract specific parameters
Code Example:
const urlModule = require('url');
const staticParams = new urlModule.URLSearchParams('token=example');
console.log(staticParams.get('token')); // Incomplete solution
Seeks guidance on the most effective method to parse URL parameters within N8N’s custom node environment.
hey! i had similr prblm b4. try using new URL(window.location.href) n then .searchParams.get('paramname'). worked 4 me in n8n custom node. might solve ur issue! lmk if it helps 
I encountered a similar challenge with URL parameter extraction in N8N. From my experience, the most reliable approach is using the `querystring` module in Node.js. Instead of relying on browser-side methods, create a utility function within your custom node that handles parameter parsing.
Here's a robust method I've used successfully: ```javascript
const querystring = require('querystring');
function extractParameters(fullUrl) {
const urlParts = fullUrl.split(‘?’);
return urlParts.length > 1 ? querystring.parse(urlParts[1]) : {};
}
<p>This approach works across different environments and provides more flexibility than browser-dependent solutions. It splits the URL, separates query parameters, and returns a clean object with key-value pairs. Make sure to add error handling and validate inputs for production use.</p>
Hey, tryed using req.query if ur node gets request context? works gr8 in n8n. u can access url params directly w/o complex parsing. btw, make sure ur node handles incoming reqst properly 