diff --git a/.env b/.env index 9123a08..5588b33 100644 --- a/.env +++ b/.env @@ -1 +1,3 @@ -WEB_URL=http://localhost:8000 \ No newline at end of file +PUBLIC_WEB_URL=http://localhost:8000 +PUBLIC_BASE_URL=http://localhost:8000/api +PUBLIC_ADMIN_URL=http://localhost:8000/admin \ No newline at end of file diff --git a/.env.production b/.env.production index 9c05eee..dca1d92 100644 --- a/.env.production +++ b/.env.production @@ -1 +1,3 @@ -WEB_URL=https://web.xuyue.cc \ No newline at end of file +PUBLIC_WEB_URL=https://web.xuyue.cc +PUBLIC_ADMIN_URL=https://web.xuyue.cc/admin +PUBLIC_BASE_URL=https://web.xuyue.cc/api \ No newline at end of file diff --git a/.env.staging b/.env.staging new file mode 100644 index 0000000..4142683 --- /dev/null +++ b/.env.staging @@ -0,0 +1,3 @@ +PUBLIC_WEB_URL=http://10.13.114.114:91 +PUBLIC_ADMIN_URL=http://10.13.114.114:91/admin +PUBLIC_BASE_URL=http://10.13.114.114:91/api \ No newline at end of file diff --git a/package.json b/package.json index f1c02c6..7d49098 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "scripts": { "start": "rsbuild dev", "build": "rsbuild build", + "build:staging": "rsbuild build --env-mode staging", "fmt": "prettier --write src/" }, "dependencies": { diff --git a/rsbuild.config.ts b/rsbuild.config.ts index 7da9a7c..6ca42ed 100644 --- a/rsbuild.config.ts +++ b/rsbuild.config.ts @@ -29,7 +29,7 @@ export default defineConfig({ server: { proxy: { "/media": { - target: process.env.WEB_URL, + target: process.env.PUBLIC_WEB_URL, changeOrigin: true, }, }, diff --git a/src/env.d.ts b/src/env.d.ts index bf2cba6..21496cf 100644 --- a/src/env.d.ts +++ b/src/env.d.ts @@ -1,5 +1,7 @@ interface ImportMetaEnv { - readonly MODE: "production" | "development" | "none" + readonly PUBLIC_WEB_URL: string + readonly PUBLIC_BASE_URL: string + readonly PUBLIC_ADMIN_URL: string } interface ImportMeta { diff --git a/src/utils/const.ts b/src/utils/const.ts index 66acf87..6e94bfd 100644 --- a/src/utils/const.ts +++ b/src/utils/const.ts @@ -35,15 +35,9 @@ export const STORAGE_KEY = { FONTSIZE: "web-fontsize", } -export const ADMIN_URL = - import.meta.env.MODE === "development" - ? "http://localhost:8000/admin" - : "https://web.xuyue.cc/admin" +export const ADMIN_URL = import.meta.env.PUBLIC_ADMIN_URL -export const BASE_URL = - import.meta.env.MODE === "development" - ? "http://localhost:8000/api" - : "https://web.xuyue.cc/api" +export const BASE_URL = import.meta.env.PUBLIC_BASE_URL export enum TASK_TYPE { Tutorial = "tutorial",