fix: use process.cwd() for database path to fix production crash

This commit is contained in:
2026-02-06 15:16:04 +08:00
parent d36f4c5b20
commit c6fc32818e
2 changed files with 2 additions and 2 deletions

View File

@@ -2,7 +2,7 @@ import Database from 'better-sqlite3';
import bcrypt from 'bcryptjs';
import path from 'path';
const dbPath = path.join(__dirname, '../data/database.sqlite');
const dbPath = path.join(process.cwd(), 'data/database.sqlite');
const db = new Database(dbPath, { verbose: console.log });
const createTables = (): void => {

View File

@@ -6,7 +6,7 @@ class DatabaseWrapper {
private dbPath: string;
constructor() {
this.dbPath = process.env.DB_PATH || path.join(__dirname, '../data/database.sqlite');
this.dbPath = process.env.DB_PATH || path.join(process.cwd(), 'data/database.sqlite');
this.db = new Database(this.dbPath, { verbose: console.log });
}