mirror of
https://gitlab.com/Binaryify/neteasecloudmusicapi.git
synced 2025-07-06 23:52:07 +08:00
allocate js cookie in middleware, update res cookie distribution
This commit is contained in:
11
app.js
11
app.js
@ -45,11 +45,20 @@ app.use(express.static(path.resolve(__dirname, 'public')))
|
||||
app.use(function(req, res, next) {
|
||||
const proxy = req.query.proxy
|
||||
if (proxy) {
|
||||
req.headers.cookie = req.headers.cookie + `__proxy__${proxy}`
|
||||
req.headers.cookie += `__proxy__${proxy}`
|
||||
}
|
||||
next()
|
||||
})
|
||||
|
||||
// 补全缺失的cookie
|
||||
const { completeCookie } = require('./util/init')
|
||||
app.use(function(req, res, next) {
|
||||
let cookie = completeCookie(req.headers.cookie)
|
||||
req.headers.cookie = cookie.map(x => x[0]).concat(req.headers.cookie || []).join('; ')
|
||||
res.append('Set-Cookie', cookie.map(x => (x.concat('Path=/').join('; '))))
|
||||
next()
|
||||
})
|
||||
|
||||
// 因为这几个文件对外所注册的路由 和 其他文件对外注册的路由规则不一样, 所以专门写个MAP对这些文件做特殊处理
|
||||
const UnusualRouteFileMap = {
|
||||
// key 为文件名, value 为对外注册的路由
|
||||
|
Reference in New Issue
Block a user