Skip to content

Commit 97f49cc

Browse files
committed
fix: reply body for 204 status and fix proxy degradation
!release: patch
1 parent 9937ebf commit 97f49cc

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class Builder {
7070
format: 'esm',
7171
outfile: join(this.distDir, 'init.js'),
7272
external: ['electron'],
73-
minify: isProduction || true,
73+
minify: isProduction || false,
7474
sourcemap: !isProduction,
7575
keepNames: true,
7676
logLevel: 'info',

config.proxy.json5

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@
1414
// Add your web proxy URLs here
1515
// "https://cloudflare-proxy-domain.example.com/",
1616
// "https://proxy.example.com/api/tunnel"
17+
18+
// 4 раза, чтобы случайно не отлетел, надо для ру-юзеров
19+
"https://soundcloud.work.gd",
20+
"https://soundcloud.work.gd",
1721
"https://soundcloud.work.gd",
22+
"https://soundcloud.work.gd",
23+
1824
"https://soundcloud-desktop-proxy-v2.sexy-loli.workers.dev",
1925
"https://soundcloud-proxy-v2.loli-hard.workers.dev",
2026
"https://sc-proxy-v2.zxcghoul.workers.dev",

src/modules/WindowSetup.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ export class WindowSetup {
342342
host.endsWith('.adsrvr.org') ||
343343
host.endsWith('.doubleclick.net') ||
344344
parsedUrl.href.includes('audio-ads') ||
345+
parsedUrl.href.includes('tsub/subscribe') ||
345346
host.endsWith('nr-data.net') ||
346347
// Google Tracking
347348
host === 'www.googletagmanager.com' ||
@@ -744,7 +745,10 @@ export class WindowSetup {
744745
responseHeaders.set(key, value);
745746
}
746747

747-
return new Response(cached.buffer, {
748+
// Определяем, запрещено ли тело для данного статуса
749+
const isNoContent = cached.status === 204 || cached.status === 205 || cached.status === 304;
750+
751+
return new Response(isNoContent ? null : cached.buffer, {
748752
status: cached.status,
749753
statusText: cached.statusText,
750754
headers: responseHeaders,
@@ -820,6 +824,20 @@ export class WindowSetup {
820824
responseHeaders.set(key, value);
821825
}
822826

827+
// Статусы 204, 205 и 304 не должны иметь тела ответа.
828+
// Мы должны принудительно передать null, иначе конструктор Response выбросит ошибку.
829+
if (
830+
nodeFetchResponse.status === 204 ||
831+
nodeFetchResponse.status === 205 ||
832+
nodeFetchResponse.status === 304
833+
) {
834+
return new Response(null, {
835+
status: nodeFetchResponse.status,
836+
statusText: nodeFetchResponse.statusText,
837+
headers: responseHeaders,
838+
});
839+
}
840+
823841
// Если нет body - возвращаем пустой ответ
824842
if (!nodeFetchResponse.body) {
825843
return new Response(null, {

0 commit comments

Comments
 (0)