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