Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/server/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,22 @@
const rawQuery = req.url.includes('?') ? req.url.slice(req.url.indexOf('?') + 1) : '';
if (rawQuery) {
parsedTarget.search = parsedTarget.search ? `${parsedTarget.search}&${rawQuery}` : `?${rawQuery}`;
targetUrl = parsedTarget.href;
}

if (parsedTarget.protocol === 'http:') parsedTarget.protocol = 'https:';
if (parsedTarget.protocol !== 'https:') {
res.status(400).type('text').send('Only HTTP(S) targets are allowed.');
return;
}

if (isPrivateHostname(parsedTarget.hostname)) {
res.status(403).type('text').send('Proxying to private or internal addresses is not allowed.');
return;
}

targetUrl = parsedTarget.href;

if (parsedTarget.protocol !== 'http:' && parsedTarget.protocol !== 'https:') {

Check failure on line 255 in src/server/proxy.ts

View workflow job for this annotation

GitHub Actions / Lint, Type-check & Build

This comparison appears to be unintentional because the types '"https:"' and '"http:"' have no overlap.
res.status(400).type('text').send('Only http and https targets are supported.');
return;
}
Expand All @@ -250,7 +262,7 @@
return;
}

if (parsedTarget.protocol === 'http:') {

Check failure on line 265 in src/server/proxy.ts

View workflow job for this annotation

GitHub Actions / Lint, Type-check & Build

This comparison appears to be unintentional because the types '"https:"' and '"http:"' have no overlap.
parsedTarget.protocol = 'https:';
targetUrl = parsedTarget.href;
}
Expand Down
Loading