Browse Source

feat: Optimize var names

butterfly 1 year ago
parent
commit
b175132854
6 changed files with 13 additions and 13 deletions
  1. 1 1
      .env.template
  2. 1 1
      README.md
  3. 3 3
      README_CN.md
  4. 5 5
      app/api/webdav/[...path]/route.ts
  5. 2 2
      app/config/server.ts
  6. 1 1
      app/constant.ts

+ 1 - 1
.env.template

@@ -60,4 +60,4 @@ ANTHROPIC_API_VERSION=
 ANTHROPIC_URL=
 
 ### (optional)
-WHITE_WEBDEV_DOMAINS=
+WHITE_WEBDEV_ENDPOINTS=

+ 1 - 1
README.md

@@ -245,7 +245,7 @@ To control custom models, use `+` to add a custom model, use `-` to hide a model
 
 User `-all` to disable all default models, `+all` to enable all default models.
 
-### `WHITE_WEBDEV_DOMAINS` (可选)
+### `WHITE_WEBDEV_ENDPOINTS` (可选)
 
 You can use this option if you want to increase the number of webdav service addresses you are allowed to access, as required by the format:
 - Each address must be a complete origin 

+ 3 - 3
README_CN.md

@@ -142,11 +142,11 @@ anthropic claude Api Url.
 
 如果你想禁用从链接解析预制设置,将此环境变量设置为 1 即可。
 
-### `WHITE_WEBDEV_DOMAINS` (可选)
+### `WHITE_WEBDEV_ENDPOINTS` (可选)
 
 如果你想增加允许访问的webdav服务地址,可以使用该选项,格式要求:
-- 每一个地址必须是一个完整的 origin 
-> `https://xxxx`
+- 每一个地址必须是一个完整的 endpoint
+> `https://xxxx/xxx`
 - 多个地址以`,`相连
 
 ### `CUSTOM_MODELS` (可选)

+ 5 - 5
app/api/webdav/[...path]/route.ts

@@ -1,12 +1,12 @@
 import { NextRequest, NextResponse } from "next/server";
-import { STORAGE_KEY, internalWhiteWebDavDomains } from "../../../constant";
+import { STORAGE_KEY, internalWhiteWebDavEndpoints } from "../../../constant";
 import { getServerSideConfig } from "@/app/config/server";
 
 const config = getServerSideConfig();
 
-const mergedWhiteWebDavDomains = [
-  ...internalWhiteWebDavDomains,
-  ...config.whiteWebDevDomains,
+const mergedWhiteWebDavEndpoints = [
+  ...internalWhiteWebDavEndpoints,
+  ...config.whiteWebDevEndpoints,
 ].filter((domain) => Boolean(domain.trim()));
 
 async function handle(
@@ -24,7 +24,7 @@ async function handle(
 
   // Validate the endpoint to prevent potential SSRF attacks
   if (
-    !mergedWhiteWebDavDomains.some((domain) => endpoint?.startsWith(domain))
+    !mergedWhiteWebDavEndpoints.some((white) => endpoint?.startsWith(white))
   ) {
     return NextResponse.json(
       {

+ 2 - 2
app/config/server.ts

@@ -79,7 +79,7 @@ export const getServerSideConfig = () => {
     `[Server Config] using ${randomIndex + 1} of ${apiKeys.length} api key`,
   );
 
-  const whiteWebDevDomains = (process.env.WHITE_WEBDEV_DOMAINS ?? "").split(
+  const whiteWebDevEndpoints = (process.env.WHITE_WEBDEV_ENDPOINTS ?? "").split(
     ",",
   );
 
@@ -116,6 +116,6 @@ export const getServerSideConfig = () => {
     hideBalanceQuery: !process.env.ENABLE_BALANCE_QUERY,
     disableFastLink: !!process.env.DISABLE_FAST_LINK,
     customModels,
-    whiteWebDevDomains,
+    whiteWebDevEndpoints,
   };
 };

+ 1 - 1
app/constant.ts

@@ -367,4 +367,4 @@ export const DEFAULT_MODELS = [
 export const CHAT_PAGE_SIZE = 15;
 export const MAX_RENDER_MSG_COUNT = 45;
 
-export const internalWhiteWebDavDomains = ["https://dav.jianguoyun.com"];
+export const internalWhiteWebDavEndpoints = ["https://dav.jianguoyun.com"];