mirror of
https://github.com/caty21/forex-dashboard.git
synced 2026-07-27 20:37:45 +00:00
fix: rate-probabilities → European region + stronger browser headers
- preferredRegion: fra1/lhr1/cdg1 to bypass US cloud IP blocks on rateprobability.com - Better sec-* headers to pass bot detection (same-origin cors mode) - cache: no-store on fetch to avoid stale null caching - Log CB count on each invocation for diagnostics Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import { fetchAllCBPaths } from "@/lib/rateprobability";
|
||||
import type { RateProbData } from "@/lib/rateprobability";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
export const preferredRegion = ["fra1", "lhr1", "cdg1"]; // Europe (Frankfurt / London / Paris)
|
||||
|
||||
export type { RateProbData, CBRatePath, RateProbMeeting } from "@/lib/rateprobability";
|
||||
|
||||
@@ -13,8 +14,10 @@ export interface RateProbabilitiesResponse {
|
||||
|
||||
export async function GET() {
|
||||
const data = await fetchAllCBPaths();
|
||||
const currencies = Object.keys(data);
|
||||
console.log(`[rate-prob] fetched ${currencies.length} CBs: ${currencies.join(", ")}`);
|
||||
return NextResponse.json(
|
||||
{ data, fetchedAt: new Date().toISOString() } satisfies RateProbabilitiesResponse,
|
||||
{ headers: { "Cache-Control": "s-maxage=3600, stale-while-revalidate=7200" } }
|
||||
{ headers: { "Cache-Control": "no-store" } }
|
||||
);
|
||||
}
|
||||
|
||||
+12
-4
@@ -100,11 +100,19 @@ async function fetchCBPath(ccy: Currency, slug: string): Promise<CBRatePath | nu
|
||||
try {
|
||||
const res = await fetch(`https://rateprobability.com/api/${slug}/latest`, {
|
||||
headers: {
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/124.0.0.0 Safari/537.36",
|
||||
"Referer": `https://rateprobability.com/${slug}`,
|
||||
"Accept": "application/json, */*",
|
||||
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36",
|
||||
"Referer": `https://rateprobability.com/${slug}`,
|
||||
"Origin": "https://rateprobability.com",
|
||||
"Accept": "application/json, text/plain, */*",
|
||||
"Accept-Language": "en-US,en;q=0.9",
|
||||
"Accept-Encoding": "gzip, deflate, br",
|
||||
"sec-ch-ua": '"Chromium";v="125", "Not.A/Brand";v="24"',
|
||||
"sec-ch-ua-mobile":"?0",
|
||||
"sec-fetch-dest": "empty",
|
||||
"sec-fetch-mode": "cors",
|
||||
"sec-fetch-site": "same-origin",
|
||||
},
|
||||
next: { revalidate: 3600 },
|
||||
cache: "no-store",
|
||||
});
|
||||
if (!res.ok) return null;
|
||||
const body = await res.json() as Record<string, unknown>;
|
||||
|
||||
Reference in New Issue
Block a user