Skip to content

Commit

Permalink
quick return when fatal error happens.
Browse files Browse the repository at this point in the history
  • Loading branch information
netptop committed Mar 6, 2020
1 parent 8648ecb commit 8c6d1fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,13 @@ let Proxy = ({httpprefix, serverName, port, cookieDomainRewrite, locationReplace
changeOrigin: true,
debug:true,
onError: (err, req, res) => {
console.log(`onerror: ${err}`)
logSave(`onerror: ${JSON.stringify(err)}`)
try {
// res.status(404).send(`{"error": "${err}"}`)
if (err.reason.indexOf('Expected') === -1) {
res.status(404).send(`{"error": "${err}"}`)
}
} catch(e) {
console.log(`error of sending 404: ${e}`)
logSave(`error of sending 404: ${e}`)
}
},
selfHandleResponse: true, // so that the onProxyRes takes care of sending the response
Expand All @@ -178,7 +180,7 @@ let Proxy = ({httpprefix, serverName, port, cookieDomainRewrite, locationReplace
logSave(`zlib.gunzip...`)
}
} catch(e) {
res.status(404).send(`{"error": "${e}"}`)
// res.status(404).send(`{"error": "${e}"}`)
return
}
if (proxyRes.headers["content-type"].indexOf('text/') !== -1 ||
Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ const siteSpecificReplace = {
'"/youtubei': `"/https/www.youtube.com/youtubei`,
'"/api/stats/"': `"/https/www.youtube.com/api/stats/"`,
'"/service_ajax"': `"/https/www.youtube.com/service_ajax"`,
// '(this\..\.logo\.hidden.*?[,;])': ``,
// '(&&this\..\.content\.insertBefore.*?;)': `;`, // && this.$.content.insertBefore(this.$.guide, this.$["page-manager"]);
},
'search.yahoo.com': {
'"./ra./click"': `"\\/https\\/search.yahoo.com\\/ra\\/click"`,
Expand Down

0 comments on commit 8c6d1fa

Please sign in to comment.