Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/routes/foresightnews/util.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,22 @@ const params = {
const rootUrl = 'https://foresightnews.pro';
const apiRootUrl = 'https://api.foresightnews.pro';
const imgRootUrl = 'https://img.foresightnews.pro';
const frontendRootUrl = 'https://s.foresightnews.pro';

const icon = new URL('foresight.ico', rootUrl).href;
const image = new URL('vertical_logo.png', imgRootUrl).href;

const apiHeaders = {
accept: 'application/json, text/plain, */*',
'accept-language': 'zh-CN,zh;q=0.9',
origin: frontendRootUrl,
referer: frontendRootUrl + '/',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-site',
'x-requested-with': 'XMLHttpRequest',
};

const processItems = async (apiUrl, limit, ...parameters) => {
let searchParams = {
size: limit,
Expand All @@ -41,6 +53,7 @@ const processItems = async (apiUrl, limit, ...parameters) => {
};

const { data: response } = await got(apiUrl, {
headers: apiHeaders,
searchParams,
});

Expand Down