I need to build a http proxy for a jpeg image inside NodeRED. My goal is that the browser does get all page resources in the dashboard from the NodeRED server. And the image is only available from another server.
I tried this abstract flow:
http-in -> http-request -> function node -> http response
In the function node I set the headers:
msg.headers = {
"content-type": "image/jpeg",
"content-disposition": "inline; filename=\"myimage.jpg\""
}
The problem is, that the browser gets these headers (excerpt):
content-type: image/jpeg; charset=utf-8
content-disposition: inline; filename="myimage.jpg"
Where the hell is charset=utf-8
coming from and how to stop NodeRED adding this?
You do not mention what msg.payload
is set to in your flow.
If the msg.payload
you pass to the HTTP Response node is a String, the content type gets the charset parameter added. This isn't deliberate behaviour of Node-RED - but something happening in the underlying http/express framework.
If msg.payload
is a Buffer object, then no such parameter is added.