mirror of
https://github.com/beilunyang/moemail.git
synced 2025-12-24 11:30:51 +08:00
chore: Change environment variable PROJECT_URL to CUSTOM_DOMAIN
This commit is contained in:
@@ -8,4 +8,4 @@ DATABASE_NAME = ""
|
||||
DATABASE_ID = ""
|
||||
KV_NAMESPACE_ID = ""
|
||||
|
||||
PROJECT_URL = ""
|
||||
CUSTOM_DOMAIN = ""
|
||||
@@ -3,7 +3,7 @@ import "dotenv/config";
|
||||
|
||||
const CF_ACCOUNT_ID = process.env.CLOUDFLARE_ACCOUNT_ID!;
|
||||
const CF_API_TOKEN = process.env.CLOUDFLARE_API_TOKEN;
|
||||
const PROJECT_URL = process.env.PROJECT_URL;
|
||||
const CUSTOM_DOMAIN = process.env.CUSTOM_DOMAIN;
|
||||
const PROJECT_NAME = process.env.PROJECT_NAME || "moemail";
|
||||
const DB_NAME = process.env.DATABASE_NAME || "moemail-db";
|
||||
const KV_NAMESPACE_NAME = process.env.KV_NAME || "moemail-kv";
|
||||
@@ -34,12 +34,12 @@ export const createPages = async () => {
|
||||
production_branch: "main",
|
||||
});
|
||||
|
||||
if (PROJECT_URL) {
|
||||
if (CUSTOM_DOMAIN) {
|
||||
console.log("🔗 Setting pages domain...");
|
||||
|
||||
await client.pages.projects.domains.create(PROJECT_NAME, {
|
||||
account_id: CF_ACCOUNT_ID,
|
||||
name: PROJECT_URL?.split("://")[1],
|
||||
name: CUSTOM_DOMAIN?.split("://")[1],
|
||||
});
|
||||
|
||||
console.log("✅ Pages domain set successfully");
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
const PROJECT_NAME = process.env.PROJECT_NAME || "moemail";
|
||||
const DATABASE_NAME = process.env.DATABASE_NAME || "moemail-db";
|
||||
const KV_NAMESPACE_NAME = process.env.KV_NAME || "moemail-kv";
|
||||
const PROJECT_URL = process.env.PROJECT_URL;
|
||||
const CUSTOM_DOMAIN = process.env.CUSTOM_DOMAIN;
|
||||
const DATABASE_ID = process.env.DATABASE_ID || "";
|
||||
const KV_NAMESPACE_ID = process.env.KV_NAMESPACE_ID || "";
|
||||
|
||||
@@ -254,13 +254,13 @@ const checkAndCreatePages = async () => {
|
||||
console.log("⚠️ Project not found, creating new project...");
|
||||
const pages = await createPages();
|
||||
|
||||
if (!PROJECT_URL && pages.subdomain) {
|
||||
console.log("⚠️ PROJECT_URL is empty, using pages default domain...");
|
||||
if (!CUSTOM_DOMAIN && pages.subdomain) {
|
||||
console.log("⚠️ CUSTOM_DOMAIN is empty, using pages default domain...");
|
||||
console.log("📝 Updating environment variables...");
|
||||
|
||||
// 更新环境变量为默认的Pages域名
|
||||
const appUrl = `https://${pages.subdomain}`;
|
||||
updateEnvVar("PROJECT_URL", appUrl);
|
||||
updateEnvVar("CUSTOM_DOMAIN", appUrl);
|
||||
}
|
||||
} else {
|
||||
console.error(`❌ An error occurred while checking the project:`, error);
|
||||
|
||||
Reference in New Issue
Block a user