Wednesday 3 May 2017

Specifically add browser to POST request in Node.js

I have a proxy endpoint in a Node.js service that is forwarding POST requests as follows:

request.post(
    fullURL,
    { form: req.body },
    function (error, response, body) {
        if (response){
            res.status(response.statusCode).send(body);
        }
        else {
            res.status(500).send("ERROR");
        }
    }
);

And this is forwarding to a Spring Boot service that is attempting to extract the browser info via:

String browser = request.getHeader("User-Agent");

But this is always empty when being forwarded through the proxy. So how can I specifically set User-Agent in the request?

NOTE: req.headers['user-agent'] from the original incoming request is all present and correct, and ready to be injected into forwarding POST request



via HomerPlata

No comments:

Post a Comment