Updated stuff
This commit is contained in:
@@ -25,6 +25,12 @@ export async function GET(req: NextRequest) {
|
|||||||
if (!auth)
|
if (!auth)
|
||||||
return NextResponse.json({ message: "Invalid token" });
|
return NextResponse.json({ message: "Invalid token" });
|
||||||
|
|
||||||
|
const ip = (req.headers.get("x-real-ip") || req.headers.get("x-forwarded-for")?.split(",")[0] || '127.0.0.1').replace('::1', '127.0.0.1');
|
||||||
|
|
||||||
|
if (auth.server_ip !== ip) {
|
||||||
|
return NextResponse.json({ message: "Invalid address" });
|
||||||
|
}
|
||||||
|
|
||||||
delete SERVER_AUTH_TOKENS[token];
|
delete SERVER_AUTH_TOKENS[token];
|
||||||
|
|
||||||
return NextResponse.json({ message: "ok", ...auth });
|
return NextResponse.json({ message: "ok", ...auth });
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@ import axios from "axios";
|
|||||||
|
|
||||||
const res = (await axios.post('http://localhost:3000/api/auth', {
|
const res = (await axios.post('http://localhost:3000/api/auth', {
|
||||||
intents: 'server',
|
intents: 'server',
|
||||||
server_ip: 'localhost'
|
server_ip: '127.0.0.1'
|
||||||
})).data;
|
})).data;
|
||||||
|
|
||||||
const token = res.token;
|
const token = res.token;
|
||||||
|
|||||||
Reference in New Issue
Block a user