Skip to content

Commit

Permalink
✨ feat: 支持配置泛域名
Browse files Browse the repository at this point in the history
  • Loading branch information
imsyy committed Nov 5, 2024
1 parent d0dfba2 commit d27ef0d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
PORT = 6688

# 允许的域名
ALLOWED_DOMAIN = "https://api-hot.imsyy.top"
ALLOWED_DOMAIN = "*"

# 允许的主域名,请填写为 imsyy.top
# 允许的主域名,填写格式为 imsyy.top
## 若填写该项,将忽略 ALLOWED_DOMAIN
ALLOWED_HOST = "imsyy.top"
ALLOWED_HOST = ""

# ROBOT
DISALLOW_ROBOT = true
Expand Down
2 changes: 1 addition & 1 deletion src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ app.use(
// 可写为数组
origin: (origin) => {
// 是否指定域名
const isSame = origin.endsWith(config.ALLOWED_HOST);
const isSame = config.ALLOWED_HOST && origin.endsWith(config.ALLOWED_HOST);
return isSame ? origin : config.ALLOWED_DOMAIN;
},
allowMethods: ["POST", "GET", "OPTIONS"],
Expand Down

0 comments on commit d27ef0d

Please sign in to comment.