From 9ad88e6cf02ad67982ada14d160d50e8385c9c80 Mon Sep 17 00:00:00 2001 From: Haodong DU Date: Fri, 26 Mar 2021 17:54:50 -0400 Subject: [PATCH] fix(route): add cookie to nga forum route (#7174) Co-authored-by: Haodong Du --- lib/routes/nga/forum.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/routes/nga/forum.js b/lib/routes/nga/forum.js index 6282964b0..c8b7542b6 100644 --- a/lib/routes/nga/forum.js +++ b/lib/routes/nga/forum.js @@ -1,7 +1,13 @@ const got = require('@/utils/got'); +const config = require('@/config').value; module.exports = async (ctx) => { const { fid, recommend } = ctx.params; + const timestamp = Math.floor(Date.now() / 1000); + let cookieString = `guestJs=${timestamp};`; + if (config.nga.uid && config.nga.cid) { + cookieString = `ngaPassportUid=${config.nga.uid}; ngaPassportCid=${config.nga.cid};`; + } const formatContent = (content) => content .replace(/\[img\](.+?)\[\/img\]/g, (match, p1) => { @@ -14,6 +20,7 @@ module.exports = async (ctx) => { url: 'https://ngabbs.com/app_api.php?__lib=subject&__act=list', headers: { 'X-User-Agent': 'NGA_skull/6.0.5(iPhone10,3;iOS 12.0.1)', + Cookie: cookieString, }, form: { fid, @@ -41,6 +48,7 @@ module.exports = async (ctx) => { url: 'https://ngabbs.com/app_api.php?__lib=post&__act=list', headers: { 'X-User-Agent': 'NGA_skull/6.0.5(iPhone10,3;iOS 12.0.1)', + Cookie: cookieString, }, form: { tid,