Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 在cloudflare cdn环境下获取ip不正确 #739

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/server/self-hosted/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -955,8 +955,8 @@

function getIp (request) {
try {
const { TWIKOO_IP_HEADERS } = process.env
const headers = TWIKOO_IP_HEADERS ? JSON.parse(TWIKOO_IP_HEADERS) : []
const TWIKOO_IP_HEADERS = process.env.TWIKOO_IP_HEADERS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应使用 解构赋值

let headers = TWIKOO_IP_HEADERS ? JSON.parse(TWIKOO_IP_HEADERS) : []

Check failure on line 959 in src/server/self-hosted/index.js

View workflow job for this annotation

GitHub Actions / build (18.x)

'headers' is never reassigned. Use 'const' instead
return getUserIP(request, headers)
} catch (e) {
logger.error('获取 IP 错误信息:', e)
Expand Down
4 changes: 2 additions & 2 deletions src/server/vercel/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -979,8 +979,8 @@

function getIp (request) {
try {
const { TWIKOO_IP_HEADERS } = process.env
const headers = TWIKOO_IP_HEADERS ? JSON.parse(TWIKOO_IP_HEADERS) : []
const TWIKOO_IP_HEADERS = process.env.TWIKOO_IP_HEADERS
let headers = TWIKOO_IP_HEADERS ? JSON.parse(TWIKOO_IP_HEADERS) : []

Check failure on line 983 in src/server/vercel/api/index.js

View workflow job for this annotation

GitHub Actions / build (18.x)

'headers' is never reassigned. Use 'const' instead
return getUserIP(request, headers)
} catch (e) {
logger.error('获取 IP 错误信息:', e)
Expand Down
Loading