fix(route): add cookie to nga forum route (#7174)
Co-authored-by: Haodong Du <duhd1993@gmail.com>
This commit is contained in:
parent
1edc3b7076
commit
9ad88e6cf0
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue