route.ts 688 B

123456789101112131415161718192021222324252627282930313233343536
  1. import { NextResponse } from "next/server";
  2. import { restApiFetch } from "@/utils/bagisto";
  3. export async function GET() {
  4. try {
  5. // const { id } = await params; // 解包拿到订单ID
  6. const apiUrl = `/home`;
  7. console.log("最终请求API地址:", apiUrl);
  8. const response = await restApiFetch<any>({
  9. api: apiUrl,
  10. method: "GET",
  11. cache: "no-store",
  12. });
  13. return NextResponse.json(response.body,{
  14. status: response.status,
  15. });
  16. } catch (error) {
  17. return NextResponse.json(
  18. {
  19. message: "Network error",
  20. error: error instanceof Error ? error.message : error,
  21. },
  22. { status: 500 }
  23. );
  24. }
  25. }