How can I set the User-Agent header using the node module?
See original GitHub issueIm trying to test that my system idenfifies user-agents correctly
using mocha, in my test code, before function - I have:
before(function(done) {
//...some actions
//...some actions
superagent.post('http://localhost:8080/api/v1/path1')
.send(body)
.set('Referrer', 'http://dummy.domain.com/somepage.html')
.set('User-Agent', "some spoofed agent")
.end(function (e, r) {
res = r;
_done();
});
})
however,the server gets
'node-superagent/1.3.0'
Help?
Issue Analytics
- State:
- Created 8 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
node.js - How to set user-agent in nodejs? - Stack Overflow
The docs for the HTTP module nodejs.org/api/http.html#http_http_request_options_callback show that agent is something different. The user-agent ...
Read more >How can I set the User-Agent header using the node module?
Im trying to test that my system idenfifies user-agents correctly using mocha, in my test code, before function - I have: ...
Read more >Handling User-Agents in Node.js - GeeksforGeeks
Setting up of User-Agent Module: To enable this module, first you need to initialize the application with package.json file and then install ......
Read more >How to set User-Agent header with Puppeteer JS and not fail
How to set User-Agent header with Puppeteer JS and not fail ... We setup Puppeteer JS, open the browser, load webpage and get...
Read more >express-useragent - npm
express-useragent is a simple NodeJS/ExpressJS user-agent middleware exposing user-agent details to your application and views. Installation.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m also having this issue when doing
with node 6.2.1.
I think it’s clear that OP was not trying to override this request from a browser, otherwise it would not have identified itself as
node-superagent/1.3.0
.EDIT: I can also confirm that the object that is being returned by
.end()
has a top level key called_headers
which does contain ‘user-agent’ (lowercase) with a value ofuaString
.npm install ionic@latest …
GitHub blocks requests without a User-Agent header