fix(route/reuters): Adjust header#22086
Draft
dzx-dzx wants to merge 3 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates Reuters route fetching to use the shared header generator presets (Modern Windows) instead of manually passing a static browser-like header set.
Changes:
- Import
PRESETSfrom the header generator utility. - Switch
ofetchcalls fromheaders: browserHeaderstoheaderGeneratorOptions: PRESETS.MODERN_WINDOWS. - Add a hardcoded
User-Agentto the localbrowserHeadersobject.
Comments suppressed due to low confidence (2)
lib/routes/reuters/common.tsx:1
- Switching from
headers: browserHeadersto onlyheaderGeneratorOptionsrisks dropping required request headers (e.g.,Accept,Accept-Language,Referer) that Reuters may rely on for correct responses. Ifofetchsupports both, passheadersalongsideheaderGeneratorOptions, or generate headers and merge in the required overrides (especiallyAcceptandReferer) before making the request.
import { load } from 'cheerio';
lib/routes/reuters/common.tsx:1
- Same issue as the content request: this section request previously sent explicit
browserHeaders, but now relies solely on the header generator preset. To avoid regressions (unexpected content negotiation, geo/language differences, or blocked responses), ensure the critical headers previously set are still applied (e.g., by mergingbrowserHeadersas overrides on top of generated headers).
import { load } from 'cheerio';
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
199
to
203
| Accept: 'application/json, text/plain, */*', | ||
| 'Accept-Language': 'en-US,en;q=0.9', | ||
| Referer: 'https://www.reuters.com/', | ||
| 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:151.0) Gecko/20100101 Firefox/151.0', | ||
| }; |
Contributor
|
Successfully generated as following: http://localhost:1200/reuters/world/china - Failed ❌ |
Contributor
Auto Review
|
Contributor
|
Successfully generated as following: http://localhost:1200/reuters/world/china - Failed ❌ |
Contributor
|
Successfully generated as following: http://localhost:1200/reuters/world/china - Failed ❌ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Involved Issue / 该 PR 相关 Issue
Close #
Example for the Proposed Route(s) / 路由地址示例
New RSS Route Checklist / 新 RSS 路由检查表
PuppeteerNote / 说明