-
-
Notifications
You must be signed in to change notification settings - Fork 858
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #279 from jason5ng32/dev
Improvements
- Loading branch information
Showing
86 changed files
with
3,250 additions
and
1,177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,3 +27,5 @@ dist-ssr | |
|
||
package-lock.json | ||
localtest | ||
|
||
.VSCodeCounter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { refererCheck } from '../common/referer-check.js'; | ||
|
||
export default async (req, res) => { | ||
|
||
// 限制只能从指定域名访问 | ||
const referer = req.headers.referer; | ||
if (!refererCheck(referer)) { | ||
return res.status(403).json({ error: referer ? 'Access denied' : 'What are you doing?' }); | ||
} | ||
|
||
const key = process.env.IPCHECKING_API_KEY; | ||
|
||
if (!key) { | ||
return res.status(500).json({ error: 'API key is missing' }); | ||
} | ||
|
||
// 构建请求 | ||
const apiEndpoint = process.env.IPCHECKING_API_ENDPOINT; | ||
const url = new URL(`${apiEndpoint}/userinfo?key=${key}`); | ||
|
||
try { | ||
const apiResponse = await fetch(url, { | ||
headers: { | ||
...req.headers, | ||
} | ||
}); | ||
|
||
if (!apiResponse.ok) { | ||
throw new Error(`API responded with status: ${apiResponse.status}`); | ||
} | ||
|
||
const data = await apiResponse.json(); | ||
res.json(data); | ||
} catch (error) { | ||
console.error("Error during API request:", error); | ||
res.status(500).json({ error: error.message }); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.