fix: pathname 有search的时候有问题

This commit is contained in:
xion 2024-10-19 12:33:38 +08:00
parent 42e32adf86
commit 73118f8454
2 changed files with 5 additions and 3 deletions

View File

@ -5,7 +5,7 @@
"main": "index.js", "main": "index.js",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "cross-env NODE_ENV=development nodemon --exec tsx src/index.ts", "dev": "cross-env NODE_ENV=development nodemon --ignore upload --exec tsx src/index.ts",
"build": "rimraf dist && rollup -c", "build": "rimraf dist && rollup -c",
"deploy": "rsync -avz dist/ light:~/apps/var-proxy/backend", "deploy": "rsync -avz dist/ light:~/apps/var-proxy/backend",
"reload": "ssh light pm2 restart proxy", "reload": "ssh light pm2 restart proxy",

View File

@ -112,8 +112,10 @@ export const handleRequest = async (req: http.IncomingMessage, res: http.ServerR
app = data.app; app = data.app;
} }
} }
const url = req.url; // const url = req.url;
if (!domainApp && noProxyUrl.includes(req.url)) { const pathname = new URL(req.url, `http://${dns.hostName}`).pathname;
const url = pathname;
if (!domainApp && noProxyUrl.includes(url)) {
res.write('No proxy for this URL\n'); res.write('No proxy for this URL\n');
return res.end(); return res.end();
} }