mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2025-03-14 15:00:07 +08:00
Add origin header to all non-GET requests
This commit is contained in:
parent
1c1ff82543
commit
ac222ef8c3
@ -1,3 +1,5 @@
|
||||
var URL = require('url');
|
||||
|
||||
var SteamCommunity = require('../index.js');
|
||||
|
||||
SteamCommunity.prototype.httpRequest = function(uri, options, callback, source) {
|
||||
@ -19,6 +21,16 @@ SteamCommunity.prototype.httpRequest = function(uri, options, callback, source)
|
||||
delete this._httpRequestConvenienceMethod;
|
||||
}
|
||||
|
||||
// Add origin header if necessary
|
||||
// https://github.com/DoctorMcKay/node-steamcommunity/issues/351
|
||||
if ((options.method || 'GET').toUpperCase() != 'GET') {
|
||||
options.headers = options.headers || {};
|
||||
if (!options.headers.origin) {
|
||||
var parsedUrl = URL.parse(options.url);
|
||||
options.headers.origin = parsedUrl.protocol + '//' + parsedUrl.host;
|
||||
}
|
||||
}
|
||||
|
||||
var requestID = ++this._httpRequestID;
|
||||
source = source || "";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user