Add sent HTTP requests by declarative style to the logs

The idea is:

Add HTTP Requests to logs

My use case:

I got 404 error with declarative style and cannot see final HTTP request that is sent

It would be really handy to see the requests that are made in node development somehow.

This is very frustrating when building nodes. Especially that the body of the error isn’t surfaced to the UI.

My first workaround was to set ignoreHttpStatusErrors: true in requestDefaults, and add a preSend and postReceive function to console log:

export async function debugRequest(
	this: IExecuteSingleFunctions,
	requestOptions: IHttpRequestOptions,
): Promise<IHttpRequestOptions> {
	console.log(`[${this.getNode().type} | ${this.getNode().name}] -`, requestOptions);
	return requestOptions;
}
export async function debugResponse(
	this: IExecuteSingleFunctions,
	items: INodeExecutionData[],
	response: IN8nHttpFullResponse,
) {
	console.log(`[${this.getNode().type} | ${this.getNode().name}] -`, response);
	return items;
}

I then call this for whichever operations I need:

{
	name: 'Instance',
	value: 'instance',
	routing: {
		send: {
			preSend: [debugRequest],
		},
		output: {
			postReceive: [debugResponse],
		},
	},
},

The other hacky workaround is to send all n8n traffic through an intercepting proxy (burp, owasp zap). Which requires updating local CAs and request mangling.

That is to say… voted!