Finastra / finastra-nodejs-libs

A set of opinionated libraries for building efficient and scalable server-side applications with Node.js
MIT License
36 stars 14 forks source link

[proxy] Request headers "accept" & "content-type" are overriden #276

Closed mathieutho closed 1 year ago

mathieutho commented 1 year ago

Hello,

I encourter the following issue.

Description

I call the proxy with headers Accept: application/xml and Content-Type: application/xml like this:

curl --request GET \ --url 'http://localhost:3000/proxy?serviceId=REFLECTION&target=%3FqueryParam1%3Dtoto%26queryParam2%3Dtata' \ --header 'Accept: application/xml' \ --header 'Content-Type: application/xml' \ --header 'my-custom-header: TOTO' \ --data '<note>reflection</note>'

The REFLECTION service just prints the request as the following: { "method": "GET", "headers": { "content-length": "70", "content-type": "application/json", "my-custom-header": "TOTO", "accept": "application/json", "cookie": "", "user-agent": "insomnia/2022.6.0", "host": "localhost:3000", "connection": "close" }, "query": { "queryParam1": "toto", "queryParam2": "tata" }, "body": "<note>reflection</note>" }

Current behaviour

The headers Accept and Content-Type received by the service are application/json.

Waited behaviour

The headers Accept and Content-Type received by the service should be application/xml.

Request

Is it possible to use the client request headers Accept and Content-Type if they are provided? https://github.com/Finastra/finastra-nodejs-libs/blob/1d53f2e73bde5092bca49cf6fb0f974d056b7114/libs/proxy/src/services/proxy.service.ts#L77 https://github.com/Finastra/finastra-nodejs-libs/blob/1d53f2e73bde5092bca49cf6fb0f974d056b7114/libs/proxy/src/services/proxy.service.ts#L78

Thank you

bcldvd commented 1 year ago

Hello Mathieu !

Considering you have already identified the fix, would you be open to making a pull request ? 🙂

mathieutho commented 1 year ago

Hello David,

I created a pull request #277

Have fun to review it ;)

Thank you

bcldvd commented 1 year ago

v0.7.1 of proxy packaging including your fix has been published ! 👏

Thanks again ;)