diff --git a/server/forwarding.js b/server/forwarding.js index a05b00b..46b4d70 100644 --- a/server/forwarding.js +++ b/server/forwarding.js @@ -7,6 +7,17 @@ const request = require('request'); +function randomString(len) { +   len = len || 32; +   var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; +   var maxPos = chars.length; +   var pwd = ''; +   for (i = 0; i < len; i++) { +     pwd += chars.charAt(Math.floor(Math.random() * maxPos)); +   } +   return pwd; +} + module.exports = { getSearchSongList:function(param,req,callback){ @@ -58,8 +69,11 @@ module.exports = { let proxy_url = 'http://www.kugou.com/yy/index.php?r=play/getdata&hash='+hash; let options = { - headers: {"Connection": "close"}, url: proxy_url, + headers: { + "Connection": "close", + "Cookie":"kg_mid="+randomString() + }, method: req.method.toUpperCase(), json: true, body: req.body