fix: Issues Around Plugin Debugger (#1885)

* proxy: Add zstd compressed payload support

Signed-off-by: Martian Potato <2260cse01024@manarat.ac.bd>

* proxy: Import types for annotations

Signed-off-by: Martian Potato <2260cse01024@manarat.ac.bd>

* components: Load novel cover via proxy

Browser blocks the image load due to CORS

Signed-off-by: Martian Potato <2260cse01024@manarat.ac.bd>

---------

Signed-off-by: Martian Potato <2260cse01024@manarat.ac.bd>
This commit is contained in:
The Couch Potato (on Mars)
2025-11-17 19:49:48 +00:00
committed by GitHub
parent 0e92630eea
commit 255ffce25f
3 changed files with 18 additions and 4 deletions
+12 -2
View File
@@ -1,8 +1,10 @@
import process from 'node:process';
import { Buffer } from 'buffer';
import { FetchMode, ServerSetting } from './src/types/types';
import { Connect } from 'vite';
import httpProxy from 'http-proxy';
import { exec } from 'child_process';
import { brotliDecompressSync, gunzipSync } from 'zlib';
import { brotliDecompressSync, gunzipSync, zstdDecompressSync } from 'zlib';
const proxy = httpProxy.createProxyServer({});
@@ -226,7 +228,13 @@ proxy.on('proxyRes', function (proxyRes, req, res) {
? contentEncoding.some(enc => enc.includes('gzip'))
: contentEncoding.includes('gzip'));
if (isBrotli || isGzip) {
const isZstd =
contentEncoding &&
(Array.isArray(contentEncoding)
? contentEncoding.some(enc => enc.includes('zstd'))
: contentEncoding.includes('zstd'));
if (isBrotli || isGzip || isZstd) {
delete proxyRes.headers['content-encoding'];
delete proxyRes.headers['content-length'];
@@ -245,6 +253,8 @@ proxy.on('proxyRes', function (proxyRes, req, res) {
if (isBrotli) {
decompressed = brotliDecompressSync(buffer);
} else if (isZstd) {
decompressed = zstdDecompressSync(buffer);
} else {
decompressed = gunzipSync(buffer);
}