fix(CipherStash-xToken): 修复代理配置逻辑
- 移除了提前初始化的代理实例 - 将代理配置移到请求参数中 - 添加了代理URL有效性检查 - 优化了请求参数结构 - 保持了原有的超时和头部配置 chore(Dockerfile): 更新构建阶段别名语法 - 将 'as builder' 改为 'AS builder' 以符合 Dockerfile 规范 - 保持基础镜像和工作目录不变 - 维持原有的依赖复制逻辑
This commit is contained in:
@@ -698,7 +698,6 @@ export async function GetXToken(str, proxy) {
|
||||
}
|
||||
|
||||
try {
|
||||
const agent = new HttpsProxyAgent(proxy);
|
||||
|
||||
let JsObj = JSON.parse(getXtokenObj(str));
|
||||
const headers = {
|
||||
@@ -707,7 +706,7 @@ export async function GetXToken(str, proxy) {
|
||||
"User-Agent": str,
|
||||
};
|
||||
|
||||
const response = await fetch(`https://jra.jd.com/jsTk.do`, {
|
||||
const formdata = {
|
||||
method: "POST",
|
||||
headers: headers,
|
||||
body: new URLSearchParams({
|
||||
@@ -715,8 +714,17 @@ export async function GetXToken(str, proxy) {
|
||||
d: JsObj.d
|
||||
}),
|
||||
timeout: 5000,
|
||||
agent: agent // 添加代理
|
||||
});
|
||||
};
|
||||
|
||||
if (proxy) {
|
||||
try {
|
||||
formdata.agent = new HttpsProxyAgent(proxy);
|
||||
} catch (e) {
|
||||
throw new Error(`Invalid proxy URL: ${proxy}`);
|
||||
}
|
||||
}
|
||||
|
||||
const response = await fetch(`https://jra.jd.com/jsTk.do`, formdata);
|
||||
|
||||
const responseData = await response.json();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# 第一阶段:安装依赖
|
||||
FROM node:24-slim as builder
|
||||
FROM node:24-slim AS builder
|
||||
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
|
||||
Reference in New Issue
Block a user