|
@@ -7,12 +7,27 @@ import jwt from "jsonwebtoken";
|
|
|
|
|
|
const JWT_SECRET = process.env.JWT_SECRET;
|
|
const JWT_SECRET = process.env.JWT_SECRET;
|
|
|
|
|
|
|
|
+// 添加调试日志
|
|
|
|
+console.log("Environment variables:", {
|
|
|
|
+ hasJwtSecret: !!process.env.JWT_SECRET,
|
|
|
|
+ jwtSecretValue: process.env.JWT_SECRET,
|
|
|
|
+ nodeEnv: process.env.NODE_ENV,
|
|
|
|
+});
|
|
|
|
+
|
|
export async function POST(request) {
|
|
export async function POST(request) {
|
|
await dbConnect();
|
|
await dbConnect();
|
|
|
|
|
|
try {
|
|
try {
|
|
const { username, password } = await request.json();
|
|
const { username, password } = await request.json();
|
|
|
|
|
|
|
|
+ if (!process.env.JWT_SECRET) {
|
|
|
|
+ console.error("JWT_SECRET is missing");
|
|
|
|
+ return NextResponse.json(
|
|
|
|
+ { success: false, error: "Server configuration error" },
|
|
|
|
+ { status: 500 }
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
let response;
|
|
let response;
|
|
|
|
|
|
// 检查所有必要字段是否都已提供
|
|
// 检查所有必要字段是否都已提供
|