diff --git a/zalo-userbot/userbot.js b/zalo-userbot/userbot.js index fec6909..21be0a4 100644 --- a/zalo-userbot/userbot.js +++ b/zalo-userbot/userbot.js @@ -22,6 +22,24 @@ process.stderr.on("error", (err) => { } }); +// Load parent .env file to sync config with Laravel +try { + const parentEnvPath = path.resolve(process.cwd(), "../.env"); + if (fs.existsSync(parentEnvPath)) { + const envContent = fs.readFileSync(parentEnvPath, "utf-8"); + envContent.split(/\r?\n/).forEach(line => { + const trimmed = line.trim(); + if (trimmed && !trimmed.startsWith("#") && trimmed.includes("=")) { + const [key, ...valueParts] = trimmed.split("="); + const value = valueParts.join("=").trim().replace(/^[\\'"\s]+|[\\'"\s]+$/g, ""); + process.env[key.trim()] = value; + } + }); + } +} catch (err) { + console.error("Warning: Failed to load parent .env file:", err.message); +} + const BASE_URL = process.env.APP_URL ? process.env.APP_URL.trim().replace(/^[\\'"\s]+|[\\'"\s]+$/g, "").replace(/\/$/, "") : "http://127.0.0.1:8000";