diff --git a/drizzle.config.ts b/drizzle.config.ts index b97a4e9..df891d0 100644 --- a/drizzle.config.ts +++ b/drizzle.config.ts @@ -7,7 +7,7 @@ export default defineConfig({ dbCredentials: { user: process.env.DB_USERNAME || 'root', password: process.env.DB_PASSWORD || '', - host: process.env.DB_HOST || '127.0.0.1' || 'localhost', + host: process.env.DB_HOST || '127.0.0.1', port: parseInt(process.env.DB_PORT || '3306'), database: process.env.DB_NAME || 'oneform_db', }, diff --git a/src/lib/db.ts b/src/lib/db.ts index cfd4d70..8373f7b 100644 --- a/src/lib/db.ts +++ b/src/lib/db.ts @@ -3,12 +3,14 @@ import {migrate} from 'drizzle-orm/mysql2/migrator'; import * as schema from '@/db/schema'; import mysql from 'mysql2/promise'; + +// import.meta.env saves envar at build time const mySqlConfig = { - host: process.env.DB_HOST || '127.0.0.1' || 'localhost', - user: process.env.DB_USER || 'root', - password: process.env.DB_PASSWORD || '', - database: process.env.DB_NAME || 'oneform_db', - port: parseInt(process.env.DB_PORT || '3306'), + host: import.meta.env.DB_HOST || '127.0.0.1', + user: import.meta.env.DB_USER || 'root', + password: import.meta.env.DB_PASSWORD || '', + database: import.meta.env.DB_NAME || 'oneform_db', + port: parseInt(import.meta.env.DB_PORT || '3306'), }; const sql = mysql.createPool(mySqlConfig);