Skip to content

Commit

Permalink
add hook host, test header detection nondanee#91
Browse files Browse the repository at this point in the history
  • Loading branch information
nondanee committed May 15, 2019
1 parent 207d8aa commit 7b57663
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ const hook = {
hook.target.host = [
'music.163.com',
'interface.music.163.com',
'interface3.music.163.com',
'apm.music.163.com',
'apm3.music.163.com',
'mam.netease.com',
'api.iplay.163.com'
// 'crash.163.com',
// 'clientlog.music.163.com'
]
Expand Down Expand Up @@ -167,7 +170,7 @@ hook.request.after = ctx => {
}

hook.connect.before = ctx => {
let url = parse('https://' + ctx.req.url)
let url = parse('https://' + (ctx.req.headers.host || ctx.req.url))
if(hook.target.host.includes(url.hostname)){
if(url.port == 80){
ctx.req.url = `localhost:${global.port[0]}`
Expand Down

0 comments on commit 7b57663

Please sign in to comment.