修复 MarketOverviewBanner 未使用 fetchBackendApi 导致生产环境 404
组件内裸 fetch() 请求到 Vercel 前端域名,缺少路由 handler 返回 404。 统一使用 fetchBackendApi() 走后端代理,其他 scan-terminal 组件已正确使用。
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import { ChevronDown, ChevronUp, Sparkles } from "lucide-react";
|
import { ChevronDown, ChevronUp, Sparkles } from "lucide-react";
|
||||||
import { useCallback, useEffect, useRef, useState } from "react";
|
import { useCallback, useEffect, useRef, useState } from "react";
|
||||||
|
import { fetchBackendApi, buildBrowserBackendHeaders } from "@/lib/backend-api";
|
||||||
import styles from "./MarketOverviewBanner.module.css";
|
import styles from "./MarketOverviewBanner.module.css";
|
||||||
import type { ScanOpportunityRow } from "@/lib/dashboard-types";
|
import type { ScanOpportunityRow } from "@/lib/dashboard-types";
|
||||||
|
|
||||||
@@ -34,9 +35,12 @@ export function MarketOverviewBanner({
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
setError(false);
|
setError(false);
|
||||||
try {
|
try {
|
||||||
const resp = await fetch("/api/scan/terminal/overview", {
|
const headers = await buildBrowserBackendHeaders({
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
});
|
||||||
|
const resp = await fetchBackendApi("/api/scan/terminal/overview", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers,
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
rows: rows.slice(0, 40).map((row) => ({
|
rows: rows.slice(0, 40).map((row) => ({
|
||||||
city: row.city ?? row.display_name ?? "",
|
city: row.city ?? row.display_name ?? "",
|
||||||
|
|||||||
Reference in New Issue
Block a user