Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Commit

Permalink
修复直接调用时传入 cookie 不生效的问题 #822
Browse files Browse the repository at this point in the history
  • Loading branch information
Binaryify committed Jun 15, 2020
1 parent ab89083 commit eb77b04
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# 更新日志
### 3.33.1 | 2020.06.15
- 修复直接调用时传入 cookie 不生效的问题 [#822](https://github.com/Binaryify/NeteaseCloudMusicApi/issues/822)

### 3.33.0 | 2020.06.10
- 歌手榜支持地区参数 [#818](https://github.com/Binaryify/NeteaseCloudMusicApi/issues/818)
- 新增视频分类列表,推荐视频,获取全部视频列表接口 [#816](https://github.com/Binaryify/NeteaseCloudMusicApi/issues/816)
Expand Down
6 changes: 5 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const request = require('./util/request')
const packageJSON = require('./package.json')
const exec = require('child_process').exec
const cache = require('./util/apicache').middleware

const { cookieToJson } = require('./util/index')
// version check
exec('npm info NeteaseCloudMusicApi version', (err, stdout, stderr) => {
if(!err){
Expand Down Expand Up @@ -66,7 +66,11 @@ fs.readdirSync(path.join(__dirname, 'module')).reverse().forEach(file => {
let question = require(path.join(__dirname, 'module', file))

app.use(route, (req, res) => {
if(typeof req.query.cookie === 'string'){
req.query.cookie = cookieToJson(req.query.cookie)
}
let query = Object.assign({}, {cookie: req.cookies}, req.query, req.body )

question(query, request)
.then(answer => {
console.log('[OK]', decodeURIComponent(req.originalUrl))
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "NeteaseCloudMusicApi",
"version": "3.33.0",
"version": "3.33.1",
"description": "网易云音乐 NodeJS 版 API",
"scripts": {
"start": "node app.js",
Expand Down
1 change: 1 addition & 0 deletions util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
return val === 'true' || val == '1'
},
cookieToJson(cookie) {
if (!cookie ) return {}
let cookieArr = cookie.split(';');
let obj = {}
cookieArr.forEach((i) => {
Expand Down

0 comments on commit eb77b04

Please sign in to comment.