Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions nodes/Puppeteer/Puppeteer.node.options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,39 @@ export const nodeDescription: INodeTypeDescription = {
default: '',
description: 'The WebSocket URL of the browser to connect to. When configured, puppeteer will skip the browser launch and connect to the browser instance.',
},
{
displayName: 'Browser WebSocket Headers',
name: 'wsHeaders',
placeholder: 'Add Header',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
},
description: 'The headers to send when connecting to the browser websocket endpoint.',
default: {},
options: [
{
name: 'parameter',
displayName: 'Header',
values: [
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
description: 'Name of the header.',
},
{
displayName: 'Value',
name: 'value',
type: 'string',
default: '',
description: 'Value to set for the header.',
},
],
},
],
},
{
displayName: 'Emulate Device',
name: 'device',
Expand Down
7 changes: 7 additions & 0 deletions nodes/Puppeteer/Puppeteer.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,13 @@ export class Puppeteer implements INodeType {
const launchArgs: IDataObject[] = launchArguments.args as IDataObject[];
const args: string[] = [];
const device = options.device as string;
const wsHeaders: HeaderObject = (options.wsHeaders as HeaderObject) || {};
const mappedWSHeaders = (wsHeaders.parameter || []).reduce((acc, header) => {
acc[header.name] = header.value;
return acc;
}, {});
const protocolTimeout = options.protocolTimeout as number;

let batchSize = options.batchSize as number;

if (!Number.isInteger(batchSize) || batchSize < 1) {
Expand Down Expand Up @@ -526,6 +532,7 @@ export class Puppeteer implements INodeType {
browser = await puppeteer.connect({
browserWSEndpoint,
protocolTimeout,
headers: mappedWSHeaders
});
} else {
browser = await puppeteer.launch({
Expand Down