Skip to content

Commit

Permalink
reduce memory to 384M
Browse files Browse the repository at this point in the history
  • Loading branch information
netptop committed Mar 12, 2020
1 parent c765c03 commit 555c642
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
14 changes: 12 additions & 2 deletions Proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ let Proxy = ({urlModify, httpprefix, serverName, port, cookieDomainRewrite, loca
if (res.statusCode == '301' || res.statusCode == '302' || res.statusCode == '303' ||res.statusCode == '307' || res.statusCode == '308') {
location = locationReplaceMap302({location, serverName, httpprefix, host, httpType})
logSave(`after replacement, location=${location}`)
res.setHeader('location', location)
try {
res.setHeader('location', location)
} catch(e) {
logSave(`error: ${e}`)
return
}
// return
}
// logSave(`HandleRespond(), req.url:${req.url}, req.headers:${JSON.stringify(req.headers)}`)
Expand Down Expand Up @@ -122,7 +127,12 @@ let Proxy = ({urlModify, httpprefix, serverName, port, cookieDomainRewrite, loca
if (typeof(body) === 'string' && body.startsWith(`${httpprefix}://${serverName}`) && body.indexOf('googlevideo.com') !== -1) {
// need to manually redirect it for youtube workaround.
console.log(`============== redirect googlevideo.com`)
res.setHeader('location', body)
try {
res.setHeader('location', body)
} catch(e) {
logSave(`error: ${e}`)
return
}
res.statusCode = '302'
}
body = zlib.gzipSync(body)
Expand Down
2 changes: 1 addition & 1 deletion now.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"functions": {
"api/main.js": {
"memory": 512,
"memory": 384,
"includeFiles": "*(*.css|*.png)"
}
},
Expand Down
4 changes: 2 additions & 2 deletions test/siteproxylocal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ test('youtube mobile url issue', async () => {
url,
})
// console.log(`${JSON.stringify(response.headers)}`)
console.log(`${response.data}`)
// console.log(`${response.data}`)
// expect(response.data.indexOf(`"Captions URL"`)).toBe(-1)
expect(response.data.indexOf(`Untrusted URL:`)).toBe(-1)
}, 30000);
Expand Down Expand Up @@ -239,4 +239,4 @@ test('youtube homepage issue', async () => {
// console.log(`${JSON.stringify(response.headers)}`)
// console.log(`${response.data}`)
expect(response.data.indexOf(`"\\/service_ajax\\",`)).toBe(-1)
}, 3000); // should be done within 3 seconds.
}, 3000); // should be done within 3 seconds.

0 comments on commit 555c642

Please sign in to comment.