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:
committed by
GitHub
parent
0e92630eea
commit
255ffce25f
@@ -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);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,10 @@ export function NovelCard({ novel, onParse }: NovelCardProps) {
|
||||
<div className="group cursor-pointer flex flex-col h-full">
|
||||
<div className="relative mb-2 overflow-hidden rounded-lg bg-muted aspect-[3/4]">
|
||||
<img
|
||||
src={novel.cover || '/static/coverNotAvailable.webp'}
|
||||
src={
|
||||
(novel.cover ? '/' : '') + novel.cover ||
|
||||
'/static/coverNotAvailable.webp'
|
||||
}
|
||||
alt={novel.name}
|
||||
className="w-full h-full object-cover group-hover:scale-105 transition-transform duration-300"
|
||||
/>
|
||||
|
||||
@@ -213,7 +213,8 @@ export default function ParseNovelSection({
|
||||
>
|
||||
<img
|
||||
src={
|
||||
sourceNovel.cover || '/static/coverNotAvailable.webp'
|
||||
(sourceNovel.cover ? '/' : '') + sourceNovel.cover ||
|
||||
'/static/coverNotAvailable.webp'
|
||||
}
|
||||
alt={sourceNovel.name}
|
||||
className="w-32 h-48 rounded-lg object-cover hover:opacity-80 transition-opacity"
|
||||
|
||||
Reference in New Issue
Block a user