Skip to content
Draft
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
15 changes: 5 additions & 10 deletions lib/routes/reuters/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ViewType } from '@/types';
import cache from '@/utils/cache';
import ofetch from '@/utils/ofetch';
import { parseDate } from '@/utils/parse-date';
import { PRESETS } from '@/utils/header-generator';

type ReutersContent = {
result: {
Expand Down Expand Up @@ -194,12 +195,6 @@ async function handler(ctx) {

const section_id = `/${category}/${topic ? `${topic}/` : ''}`;

const browserHeaders = {
Accept: 'application/json, text/plain, */*',
'Accept-Language': 'en-US,en;q=0.9',
Referer: 'https://www.reuters.com/',
};

try {
const { title, description, rootUrl, response } = await (async () => {
if (MUST_FETCH_BY_TOPICS.has(category)) {
Expand All @@ -213,7 +208,7 @@ async function handler(ctx) {
website: 'reuters',
}),
},
headers: browserHeaders,
headerGeneratorOptions: PRESETS.MODERN_WINDOWS,
});

return {
Expand All @@ -240,7 +235,7 @@ async function handler(ctx) {
: {}),
}),
},
headers: browserHeaders,
headerGeneratorOptions: PRESETS.MODERN_WINDOWS,
});
return {
title: response.result.section.title,
Expand Down Expand Up @@ -269,7 +264,7 @@ async function handler(ctx) {
ctx.req.query('fulltext') === 'true'
? cache.tryGet(item.link, async () => {
const detailResponse = await ofetch(item.link, {
headers: browserHeaders,
headerGeneratorOptions: PRESETS.MODERN_WINDOWS,
});
const content = load(detailResponse.data);

Expand Down Expand Up @@ -337,7 +332,7 @@ async function handler(ctx) {
const arcUrl = topic ? `https://www.reuters.com/arc/outboundfeeds/v4/mobile/section${section_id}?outputType=json` : `https://www.reuters.com/arc/outboundfeeds/v4/mobile/section/${category}/?outputType=json`;

const arcResponse = await ofetch(arcUrl, {
headers: browserHeaders,
headerGeneratorOptions: PRESETS.MODERN_WINDOWS,
});
if (arcResponse.wireitems?.length) {
const items = arcResponse.wireitems
Expand Down
Loading