mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-30 18:46:01 +01:00 
			
		
		
		
	fix: set a user-agent when sending requests
This commit is contained in:
		| @@ -1,5 +1,6 @@ | ||||
| 'use strict'; | ||||
|  | ||||
| const nconf = require('nconf'); | ||||
| const { CookieJar } = require('tough-cookie'); | ||||
| const fetchCookie = require('fetch-cookie').default; | ||||
|  | ||||
| @@ -9,6 +10,8 @@ exports.jar = function () { | ||||
|  | ||||
| // Initialize fetch - somewhat hacky, but it's required for globalDispatcher to be available | ||||
|  | ||||
| const userAgent = `NodeBB/${nconf.get('version').split('.').shift()}.x`; | ||||
|  | ||||
| async function call(url, method, { body, timeout, jar, ...config } = {}) { | ||||
| 	let fetchImpl = fetch; | ||||
| 	if (jar) { | ||||
| @@ -20,6 +23,7 @@ async function call(url, method, { body, timeout, jar, ...config } = {}) { | ||||
| 		method, | ||||
| 		headers: { | ||||
| 			'content-type': 'application/json', | ||||
| 			'user-agent': userAgent, | ||||
| 			...config.headers, | ||||
| 		}, | ||||
| 	}; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user