[refactor] proxy2

This commit is contained in:
kwaroran
2023-07-07 06:20:02 +09:00
parent 73b86f0a64
commit ead670516d
8 changed files with 76 additions and 87 deletions

View File

@@ -40,7 +40,7 @@ app.get('/', async (req, res, next) => {
}
})
app.post('/proxy', async (req, res, next) => {
const proxyFunc = async (req, res, next) => {
const urlParam = req.query.url;
if (!urlParam) {
@@ -67,12 +67,20 @@ app.post('/proxy', async (req, res, next) => {
const status = originalResponse.status;
const originalBody = await originalResponse.text();
const head = originalResponse.headers
head.delete('content-security-policy');
head.delete('content-security-policy-report-only');
head.delete('clear-site-data');
head.delete('Cache-Control');
if(status < 200 || status >= 300){
res.status(status)
}
res.header(head)
res.send(originalBody);
});
}
app.post('/proxy', proxyFunc);
app.post('/proxy2', proxyFunc);
app.get('/api/password', async(req, res)=> {
if(password === ''){