feat: 添加 API 客户端以处理 basePath 并更新所有 fetch 调用
移除 next.config.js 中的 standalone 输出配置,添加 lib/api-client.ts 封装 fetch 请求, 自动为所有 API 调用添加配置的 basePath。更新所有页面和组件中的 fetch 调用以使用新的 fetchApi 函数, 确保在部署到子路径时 API 请求能正确工作。同时调整 tsconfig.json 的格式并修复项目创建时的字段名。
This commit is contained in:
@@ -4,6 +4,7 @@ import { useState } from 'react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { Target, Loader2, Sparkles, CheckCircle } from 'lucide-react';
|
||||
import { fetchApi } from '@/lib/api-client';
|
||||
|
||||
interface InitWizardProps {
|
||||
onComplete: () => void;
|
||||
@@ -19,7 +20,7 @@ export function InitWizard({ onComplete }: InitWizardProps) {
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/seed', { method: 'POST' });
|
||||
const res = await fetchApi('/api/seed', { method: 'POST' });
|
||||
const data = await res.json();
|
||||
|
||||
if (!res.ok) {
|
||||
|
||||
Reference in New Issue
Block a user