chore: disable remote debugger by default (#17498)

This commit is contained in:
Tony
2024-11-08 04:08:05 +08:00
committed by GitHub
parent 3699679206
commit 4e404a7328
4 changed files with 15 additions and 4 deletions
+11 -1
View File
@@ -5,12 +5,14 @@ import { ofetch } from 'ofetch';
let envs = process.env;
export type Config = {
// app config
disallowRobot: boolean;
enableCluster?: string;
isPackage: boolean;
nodeName?: string;
puppeteerWSEndpoint?: string;
chromiumExecutablePath?: string;
// network
connect: {
port: number;
};
@@ -20,6 +22,7 @@ export type Config = {
ua: string;
trueUA: string;
allowOrigin?: string;
// cache
cache: {
type: string;
requestTimeout: number;
@@ -32,6 +35,7 @@ export type Config = {
redis: {
url: string;
};
// proxy
proxyUri?: string;
proxy: {
protocol?: string;
@@ -43,7 +47,9 @@ export type Config = {
};
pacUri?: string;
pacScript?: string;
// access control
accessKey?: string;
// logging
debugInfo: string;
loggerLevel: string;
noLogfiles?: boolean;
@@ -56,6 +62,8 @@ export type Config = {
dsn?: string;
routeTimeout: number;
};
enableRemoteDebugging?: boolean;
// feed config
hotlink: {
template?: string;
includePaths?: string[];
@@ -78,6 +86,8 @@ export type Config = {
promptTitle: string;
promptDescription: string;
};
// Route-specific Configurations
bilibili: {
cookies: Record<string, string | undefined>;
dmImgList?: string;
@@ -426,7 +436,6 @@ const calculateValue = () => {
requestTimeout: toInt(envs.REQUEST_TIMEOUT, 30000), // Milliseconds to wait for the server to end the response before aborting the request
ua: envs.UA ?? (toBoolean(envs.NO_RANDOM_UA, false) ? TRUE_UA : randUserAgent({ browser: 'chrome', os: 'mac os', device: 'desktop' })),
trueUA: TRUE_UA,
// cors request
allowOrigin: envs.ALLOW_ORIGIN,
// cache
cache: {
@@ -470,6 +479,7 @@ const calculateValue = () => {
dsn: envs.SENTRY,
routeTimeout: toInt(envs.SENTRY_ROUTE_TIMEOUT, 30000),
},
enableRemoteDebugging: toBoolean(envs.ENABLE_REMOTE_DEBUGGING, false),
// feed config
hotlink: {
template: envs.HOTLINK_TEMPLATE,
+1 -1
View File
@@ -3,7 +3,7 @@ import { config } from '@/config';
import logger from '@/utils/logger';
import { register } from 'node-network-devtools';
process.env.NODE_ENV === 'dev' && register();
config.enableRemoteDebugging && process.env.NODE_ENV === 'dev' && register();
const rofetch = createFetch().create({
retryStatusCodes: [400, 408, 409, 425, 429, 500, 502, 503, 504],
+1
View File
@@ -25,6 +25,7 @@ describe('useCustomHeader', () => {
beforeEach(() => {
originalEnv = process.env.NODE_ENV || Env.test;
process.env.ENABLE_REMOTE_DEBUGGING = 'true';
});
afterEach(() => {
+2 -2
View File
@@ -12,7 +12,7 @@ const limiter = new RateLimiterMemory({
});
const limiterQueue = new RateLimiterQueue(limiter, {
maxQueueSize: 5000,
maxQueueSize: 4800,
});
export const useCustomHeader = (headers: Headers) => {
@@ -57,7 +57,7 @@ const wrappedFetch: typeof undici.fetch = async (input: RequestInfo, init?: Requ
request.headers.delete('x-prefer-proxy');
}
useCustomHeader(request.headers);
config.enableRemoteDebugging && useCustomHeader(request.headers);
// proxy
if (!init?.dispatcher && proxy.dispatcher && (proxy.proxyObj.strategy !== 'on_retry' || isRetry)) {