fix(frontend): say the database is missing, not Supabase
Self-hosted PostgreSQL is the runtime. A missing APP_DATABASE_URL must not tell users the retired hosted service is unconfigured. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -161,7 +161,7 @@ export async function GET() {
|
||||
});
|
||||
} catch (error) {
|
||||
if (isSupabaseConfigurationError(error)) {
|
||||
return NextResponse.json({ error: "Supabase 尚未配置", code: "SUPABASE_NOT_CONFIGURED" }, { status: 503 });
|
||||
return NextResponse.json({ error: "数据库尚未配置", code: "DATABASE_NOT_CONFIGURED" }, { status: 503 });
|
||||
}
|
||||
return NextResponse.json({ error: "账户服务暂时不可用" }, { status: 500 });
|
||||
}
|
||||
@@ -346,7 +346,7 @@ export async function PATCH(request: Request) {
|
||||
});
|
||||
} catch (error) {
|
||||
if (isSupabaseConfigurationError(error)) {
|
||||
return NextResponse.json({ error: "Supabase 尚未配置", code: "SUPABASE_NOT_CONFIGURED" }, { status: 503 });
|
||||
return NextResponse.json({ error: "数据库尚未配置", code: "DATABASE_NOT_CONFIGURED" }, { status: 503 });
|
||||
}
|
||||
return NextResponse.json({ error: "账户服务暂时不可用" }, { status: 500 });
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ export async function POST(request: Request) {
|
||||
} catch (error) {
|
||||
if (isSupabaseConfigurationError(error)) {
|
||||
return NextResponse.json(
|
||||
{ error: "服务尚未配置", message: "请先配置 Supabase 环境变量。" },
|
||||
{ error: "服务尚未配置", message: "请先配置数据库环境变量。" },
|
||||
{ status: 503 },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ export async function POST(request: Request) {
|
||||
} catch (error) {
|
||||
if (isSupabaseConfigurationError(error)) {
|
||||
return NextResponse.json(
|
||||
{ error: "服务尚未配置", message: "请先配置 Supabase 环境变量。" },
|
||||
{ error: "服务尚未配置", message: "请先配置数据库环境变量。" },
|
||||
{ status: 503 },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ export async function DELETE(_request: Request, context: RouteContext) {
|
||||
return NextResponse.json({ ok: true });
|
||||
} catch (error) {
|
||||
if (isSupabaseConfigurationError(error)) {
|
||||
return NextResponse.json({ error: "Supabase 尚未配置", code: "SUPABASE_NOT_CONFIGURED" }, { status: 503 });
|
||||
return NextResponse.json({ error: "数据库尚未配置", code: "DATABASE_NOT_CONFIGURED" }, { status: 503 });
|
||||
}
|
||||
return NextResponse.json({ error: errorMessage(error, "星盘删除失败") }, { status: 500 });
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ export async function GET() {
|
||||
return NextResponse.json({ profiles: data ?? [] });
|
||||
} catch (error) {
|
||||
if (isSupabaseConfigurationError(error)) {
|
||||
return NextResponse.json({ error: "Supabase 尚未配置", code: "SUPABASE_NOT_CONFIGURED" }, { status: 503 });
|
||||
return NextResponse.json({ error: "数据库尚未配置", code: "DATABASE_NOT_CONFIGURED" }, { status: 503 });
|
||||
}
|
||||
return NextResponse.json({ error: errorMessage(error, "星盘库暂时不可用") }, { status: 500 });
|
||||
}
|
||||
@@ -81,7 +81,7 @@ export async function POST(request: Request) {
|
||||
return NextResponse.json({ profile: data });
|
||||
} catch (error) {
|
||||
if (isSupabaseConfigurationError(error)) {
|
||||
return NextResponse.json({ error: "Supabase 尚未配置", code: "SUPABASE_NOT_CONFIGURED" }, { status: 503 });
|
||||
return NextResponse.json({ error: "数据库尚未配置", code: "DATABASE_NOT_CONFIGURED" }, { status: 503 });
|
||||
}
|
||||
return NextResponse.json({ error: errorMessage(error, "星盘保存失败") }, { status: 500 });
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ export async function POST(request: Request) {
|
||||
accounting = createAdminSupabaseClient();
|
||||
} catch {
|
||||
return NextResponse.json(
|
||||
{ error: "服务尚未配置", message: "请先配置 Supabase 环境变量。" },
|
||||
{ error: "服务尚未配置", message: "请先配置数据库环境变量。" },
|
||||
{ status: 503 },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ export async function POST(request: Request) {
|
||||
accounting = createAdminSupabaseClient();
|
||||
} catch {
|
||||
return NextResponse.json(
|
||||
{ error: "服务尚未配置", message: "请先配置 Supabase 环境变量。" },
|
||||
{ error: "服务尚未配置", message: "请先配置数据库环境变量。" },
|
||||
{ status: 503 },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ export async function GET() {
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
return NextResponse.json(
|
||||
{ error: "服务尚未配置", message: "请先配置 Supabase 环境变量。" },
|
||||
{ error: "服务尚未配置", message: "请先配置数据库环境变量。" },
|
||||
{ status: 503 },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ export async function GET() {
|
||||
} catch (error) {
|
||||
if (isSupabaseConfigurationError(error)) {
|
||||
return NextResponse.json(
|
||||
{ error: "Supabase 尚未配置", code: "SUPABASE_NOT_CONFIGURED" },
|
||||
{ error: "数据库尚未配置", code: "DATABASE_NOT_CONFIGURED" },
|
||||
{ status: 503 },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ export async function POST(request: Request) {
|
||||
} catch (error) {
|
||||
if (isSupabaseConfigurationError(error)) {
|
||||
return NextResponse.json(
|
||||
{ error: "Supabase 尚未配置", code: "SUPABASE_NOT_CONFIGURED" },
|
||||
{ error: "数据库尚未配置", code: "DATABASE_NOT_CONFIGURED" },
|
||||
{ status: 503 },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ export async function GET(request: Request, context: RouteContext) {
|
||||
} catch (error) {
|
||||
if (isSupabaseConfigurationError(error)) {
|
||||
return NextResponse.json(
|
||||
{ error: "Supabase 尚未配置", code: "SUPABASE_NOT_CONFIGURED" },
|
||||
{ error: "数据库尚未配置", code: "DATABASE_NOT_CONFIGURED" },
|
||||
{ status: 503 },
|
||||
);
|
||||
}
|
||||
@@ -122,7 +122,7 @@ export async function DELETE(request: Request, context: RouteContext) {
|
||||
} catch (error) {
|
||||
if (isSupabaseConfigurationError(error)) {
|
||||
return NextResponse.json(
|
||||
{ error: "Supabase 尚未配置", code: "SUPABASE_NOT_CONFIGURED" },
|
||||
{ error: "数据库尚未配置", code: "DATABASE_NOT_CONFIGURED" },
|
||||
{ status: 503 },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ export async function GET() {
|
||||
} catch (error) {
|
||||
if (isSupabaseConfigurationError(error)) {
|
||||
return NextResponse.json(
|
||||
{ error: "Supabase 尚未配置", code: "SUPABASE_NOT_CONFIGURED" },
|
||||
{ error: "数据库尚未配置", code: "DATABASE_NOT_CONFIGURED" },
|
||||
{ status: 503 },
|
||||
);
|
||||
}
|
||||
@@ -211,7 +211,7 @@ export async function POST(request: Request) {
|
||||
} catch (error) {
|
||||
if (isSupabaseConfigurationError(error)) {
|
||||
return NextResponse.json(
|
||||
{ error: "Supabase 尚未配置", code: "SUPABASE_NOT_CONFIGURED" },
|
||||
{ error: "数据库尚未配置", code: "DATABASE_NOT_CONFIGURED" },
|
||||
{ status: 503 },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ export async function PATCH(request: Request, context: RouteContext) {
|
||||
return NextResponse.json({ error: error.message }, { status: 413 });
|
||||
}
|
||||
if (isSupabaseConfigurationError(error)) {
|
||||
return NextResponse.json({ error: "Supabase 尚未配置", code: "SUPABASE_NOT_CONFIGURED" }, { status: 503 });
|
||||
return NextResponse.json({ error: "数据库尚未配置", code: "DATABASE_NOT_CONFIGURED" }, { status: 503 });
|
||||
}
|
||||
return NextResponse.json({ error: "聊天记录暂时无法同步" }, { status: 500 });
|
||||
}
|
||||
@@ -74,7 +74,7 @@ export async function DELETE(_request: Request, context: RouteContext) {
|
||||
return NextResponse.json({ ok: true });
|
||||
} catch (error) {
|
||||
if (isSupabaseConfigurationError(error)) {
|
||||
return NextResponse.json({ error: "Supabase 尚未配置", code: "SUPABASE_NOT_CONFIGURED" }, { status: 503 });
|
||||
return NextResponse.json({ error: "数据库尚未配置", code: "DATABASE_NOT_CONFIGURED" }, { status: 503 });
|
||||
}
|
||||
return NextResponse.json({ error: error instanceof Error ? error.message : "删除聊天记录失败" }, { status: 500 });
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ export async function POST(request: Request) {
|
||||
return NextResponse.json({ error: error.message }, { status: 413 });
|
||||
}
|
||||
if (isSupabaseConfigurationError(error)) {
|
||||
return NextResponse.json({ error: "Supabase 尚未配置", code: "SUPABASE_NOT_CONFIGURED" }, { status: 503 });
|
||||
return NextResponse.json({ error: "数据库尚未配置", code: "DATABASE_NOT_CONFIGURED" }, { status: 503 });
|
||||
}
|
||||
return NextResponse.json({ error: "聊天记录暂时无法同步" }, { status: 500 });
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ export async function GET() {
|
||||
return NextResponse.json({ reports: data ?? [] });
|
||||
} catch (error) {
|
||||
if (isSupabaseConfigurationError(error)) {
|
||||
return NextResponse.json({ error: "Supabase 尚未配置", code: "SUPABASE_NOT_CONFIGURED" }, { status: 503 });
|
||||
return NextResponse.json({ error: "数据库尚未配置", code: "DATABASE_NOT_CONFIGURED" }, { status: 503 });
|
||||
}
|
||||
return NextResponse.json({ error: errorMessage(error, "合盘历史暂时不可用") }, { status: 500 });
|
||||
}
|
||||
@@ -78,7 +78,7 @@ export async function POST(request: Request) {
|
||||
return NextResponse.json({ report: data });
|
||||
} catch (error) {
|
||||
if (isSupabaseConfigurationError(error)) {
|
||||
return NextResponse.json({ error: "Supabase 尚未配置", code: "SUPABASE_NOT_CONFIGURED" }, { status: 503 });
|
||||
return NextResponse.json({ error: "数据库尚未配置", code: "DATABASE_NOT_CONFIGURED" }, { status: 503 });
|
||||
}
|
||||
return NextResponse.json({ error: errorMessage(error, "合盘历史保存失败") }, { status: 500 });
|
||||
}
|
||||
|
||||
@@ -944,8 +944,11 @@ function isProfileComplete(profile: Profile) {
|
||||
}
|
||||
|
||||
function friendlyError(message: string) {
|
||||
return message.includes("Supabase") && (message.includes("配置") || message.includes("environment") || message.includes("URL"))
|
||||
? "Supabase 尚未配置"
|
||||
return (
|
||||
message.includes("数据库配置缺失")
|
||||
|| (message.includes("Supabase") && (message.includes("配置") || message.includes("environment") || message.includes("URL")))
|
||||
)
|
||||
? "数据库尚未配置"
|
||||
: message;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ function authMessage(caught: unknown) {
|
||||
message.includes("environment") ||
|
||||
message.includes("URL")
|
||||
)
|
||||
return "Supabase 尚未配置";
|
||||
return "数据库尚未配置";
|
||||
if (lower.includes("expired") || lower.includes("invalid"))
|
||||
return "验证码错误或已过期,请重新获取";
|
||||
if (lower.includes("rate limit")) return "发送过于频繁,请稍后再试";
|
||||
|
||||
@@ -148,7 +148,7 @@ export function createOnboardingPost(dependencies: OnboardingPostDependencies):
|
||||
session = await dependencies.openSession();
|
||||
} catch { // no-excuse-ok: catch -- route boundary converts missing configuration.
|
||||
return Response.json(
|
||||
{ error: "服务尚未配置", message: "请先配置 Supabase 环境变量。" },
|
||||
{ error: "服务尚未配置", message: "请先配置数据库环境变量。" },
|
||||
{ status: 503 },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
export class SupabaseConfigurationError extends Error {
|
||||
readonly code = "SUPABASE_NOT_CONFIGURED";
|
||||
readonly code = "DATABASE_NOT_CONFIGURED";
|
||||
|
||||
constructor(missing: string[]) {
|
||||
super(`Supabase 配置缺失:${missing.join(", ")}`);
|
||||
super(`数据库配置缺失:${missing.join(", ")}`);
|
||||
this.name = "SupabaseConfigurationError";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user