diff --git a/app.js b/app.js index 4ac39d4..0520f73 100644 --- a/app.js +++ b/app.js @@ -53,7 +53,6 @@ const loadAPIRoutes = (baseDir = 'api', baseRoute = '/api') => { // 初始化扫描 scanDirectory(path.join(__dirname, baseDir), baseRoute); }; - // 公开路由 router.get("/public", (ctx) => { ctx.body = "Public content"; diff --git a/auth/3xuiLogin.js b/auth/3xuiLogin.js new file mode 100644 index 0000000..e71713f --- /dev/null +++ b/auth/3xuiLogin.js @@ -0,0 +1,19 @@ +const instance = require("../utils/http"); + +function getCookie() { + const formData = new FormData(); + formData.append("username", "lsw"); + formData.append("password", "lsw@2024"); + formData.append("loginSecret", "IEuVG4csTWLuaq3ysuUSHdwOcnoQRfScURwJVBjCMjRRpjVyYhWcgaHIJvU0SV4P"); + return instance + .post("/login", formData, { + maxRedirects: 0, // 禁止自动重定向以保留Cookie + withCredentials: true, // 确保携带凭证 + }) + .then((res) => { + const rawCookies = res.headers["set-cookie"] || []; + const cookies =["lang=zh-CN",rawCookies.at(-1)?.split(";")[0]].join(";"); + return cookies; + }); +} +module.exports = getCookie;