UPDATE: Update readme and Next 16.07 (CVE-2025-66478)

This commit is contained in:
2025-12-04 23:27:41 +07:00
commit 6b079db470
280 changed files with 364214 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
import { NextRequest, NextResponse } from 'next/server'
import { loadAS } from '@/lib/loader'
export async function GET(
req: NextRequest,
{ params }: { params: Promise<{ id: string, locale: string }> }
) {
const { id, locale } = await params
const asData = await loadAS([id], locale)
const as = asData[id]
if (!as) {
return NextResponse.json({ error: 'AS info not found' }, { status: 404 })
}
return new NextResponse(JSON.stringify(as), {
headers: { "Content-Type": "application/json" }
});
}
+22
View File
@@ -0,0 +1,22 @@
import { loadAS } from "@/lib/loader";
import { NextRequest, NextResponse } from "next/server";
export async function POST(request: NextRequest, { params }: { params: Promise<{ locale: string }> }) {
try {
const body = await request.json();
const asIds = body.asIds as string[];
const { locale } = await params;
if (!Array.isArray(asIds) || asIds.some(id => typeof id !== 'string')) {
return NextResponse.json({ error: 'Invalid asIds' }, { status: 400 });
}
const asData = await loadAS(asIds, locale);
return new NextResponse(JSON.stringify(asData), {
headers: { "Content-Type": "application/json" }
});
} catch {
return NextResponse.json({ error: 'Failed to load as data' }, { status: 500 });
}
}
@@ -0,0 +1,20 @@
import { NextRequest, NextResponse } from 'next/server'
import { loadCharacters } from '@/lib/loader'
export async function GET(
req: NextRequest,
{ params }: { params: Promise<{ id: string, locale: string }> }
) {
const { id, locale } = await params
const characters = await loadCharacters([id], locale)
const char = characters[id]
if (!char) {
return NextResponse.json({ error: 'Character not found' }, { status: 404 })
}
return new NextResponse(JSON.stringify(char), {
headers: { "Content-Type": "application/json" }
});
}
+22
View File
@@ -0,0 +1,22 @@
import { loadCharacters } from "@/lib/loader";
import { NextRequest, NextResponse } from "next/server";
export async function POST(request: NextRequest, { params }: { params: Promise<{ locale: string }> }) {
try {
const body = await request.json();
const charIds = body.charIds as string[];
const { locale } = await params;
if (!Array.isArray(charIds) || charIds.some(id => typeof id !== 'string')) {
return NextResponse.json({ error: 'Invalid charIds' }, { status: 400 });
}
const characters = await loadCharacters(charIds, locale);
return new NextResponse(JSON.stringify(characters), {
headers: { "Content-Type": "application/json" }
});
} catch {
return NextResponse.json({ error: 'Failed to load characters' }, { status: 500 });
}
}
@@ -0,0 +1,20 @@
import { NextRequest, NextResponse } from 'next/server'
import { loadLightcones } from '@/lib/loader'
export async function GET(
req: NextRequest,
{ params }: { params: Promise<{ id: string, locale: string }> }
) {
const { id, locale } = await params
const lightcones = await loadLightcones([id], locale)
const lightcone = lightcones[id]
if (!lightcone) {
return NextResponse.json({ error: 'Lightcone not found' }, { status: 404 })
}
return new NextResponse(JSON.stringify(lightcone), {
headers: { "Content-Type": "application/json" }
});
}
+22
View File
@@ -0,0 +1,22 @@
import { loadLightcones } from "@/lib/loader";
import { NextRequest, NextResponse } from "next/server";
export async function POST(request: NextRequest, { params }: { params: Promise<{ locale: string }> }) {
try {
const body = await request.json();
const lightconeIds = body.lightconeIds as string[];
const { locale } = await params;
if (!Array.isArray(lightconeIds) || lightconeIds.some(id => typeof id !== 'string')) {
return NextResponse.json({ error: 'Invalid lightconeIds' }, { status: 400 });
}
const lightcones = await loadLightcones(lightconeIds, locale);
return new NextResponse(JSON.stringify(lightcones), {
headers: { "Content-Type": "application/json" }
});
} catch {
return NextResponse.json({ error: 'Failed to load lightcones' }, { status: 500 });
}
}
+20
View File
@@ -0,0 +1,20 @@
import { NextRequest, NextResponse } from 'next/server'
import { loadMOC } from '@/lib/loader'
export async function GET(
req: NextRequest,
{ params }: { params: Promise<{ id: string, locale: string }> }
) {
const { id, locale } = await params
const mocData = await loadMOC([id], locale)
const moc = mocData[id]
if (!moc) {
return NextResponse.json({ error: 'MOC info not found' }, { status: 404 })
}
return new NextResponse(JSON.stringify(moc), {
headers: { "Content-Type": "application/json" }
});
}
+22
View File
@@ -0,0 +1,22 @@
import { loadMOC } from "@/lib/loader";
import { NextRequest, NextResponse } from "next/server";
export async function POST(request: NextRequest, { params }: { params: Promise<{ locale: string }> }) {
try {
const body = await request.json();
const mocIds = body.mocIds as string[];
const { locale } = await params;
if (!Array.isArray(mocIds) || mocIds.some(id => typeof id !== 'string')) {
return NextResponse.json({ error: 'Invalid mocIds' }, { status: 400 });
}
const mocData = await loadMOC(mocIds, locale);
return new NextResponse(JSON.stringify(mocData), {
headers: { "Content-Type": "application/json" }
});
} catch {
return NextResponse.json({ error: 'Failed to load moc data' }, { status: 500 });
}
}
@@ -0,0 +1,19 @@
import { NextRequest, NextResponse } from 'next/server'
import { loadMonster } from '@/lib/loader'
export async function GET(
req: NextRequest,
{ params }: { params: Promise<{ id: string, locale: string }> }
) {
const { id, locale } = await params
const monsterData = await loadMonster([id], locale)
const monster = monsterData[id]
if (!monster) {
return NextResponse.json({ error: 'Monster info not found' }, { status: 404 })
}
return new NextResponse(JSON.stringify(monster), {
headers: { "Content-Type": "application/json" }
});
}
+22
View File
@@ -0,0 +1,22 @@
import { loadMonster } from "@/lib/loader";
import { NextRequest, NextResponse } from "next/server";
export async function POST(request: NextRequest, { params }: { params: Promise<{ locale: string }> }) {
try {
const body = await request.json();
const monsterIds = body.monsterIds as string[];
const { locale } = await params;
if (!Array.isArray(monsterIds) || monsterIds.some(id => typeof id !== 'string')) {
return NextResponse.json({ error: 'Invalid monsterIds' }, { status: 400 });
}
const monsterData = await loadMonster(monsterIds, locale);
return new NextResponse(JSON.stringify(monsterData), {
headers: { "Content-Type": "application/json" }
});
} catch {
return NextResponse.json({ error: 'Failed to load monster data' }, { status: 500 });
}
}
+20
View File
@@ -0,0 +1,20 @@
import { NextRequest, NextResponse } from 'next/server'
import { loadPeak } from '@/lib/loader'
export async function GET(
req: NextRequest,
{ params }: { params: Promise<{ id: string, locale: string }> }
) {
const { id, locale } = await params
const peakData = await loadPeak([id], locale)
const peak = peakData[id]
if (!peak) {
return NextResponse.json({ error: 'Peak info not found' }, { status: 404 })
}
return new NextResponse(JSON.stringify(peak), {
headers: { "Content-Type": "application/json" }
});
}
+22
View File
@@ -0,0 +1,22 @@
import { loadPeak } from "@/lib/loader";
import { NextRequest, NextResponse } from "next/server";
export async function POST(request: NextRequest, { params }: { params: Promise<{ locale: string }> }) {
try {
const body = await request.json();
const peakIds = body.peakIds as string[];
const { locale } = await params;
if (!Array.isArray(peakIds) || peakIds.some(id => typeof id !== 'string')) {
return NextResponse.json({ error: 'Invalid peakIds' }, { status: 400 });
}
const peakData = await loadPeak(peakIds, locale);
return new NextResponse(JSON.stringify(peakData), {
headers: { "Content-Type": "application/json" }
});
} catch {
return NextResponse.json({ error: 'Failed to load peak data' }, { status: 500 });
}
}
+21
View File
@@ -0,0 +1,21 @@
import { NextRequest, NextResponse } from 'next/server'
import { loadPF } from '@/lib/loader'
export async function GET(
req: NextRequest,
{ params }: { params: Promise<{ id: string, locale: string }> }
) {
const { id, locale } = await params
const pfData = await loadPF([id], locale)
const pf = pfData[id]
if (!pf) {
return NextResponse.json({ error: 'PF info not found' }, { status: 404 })
}
return new NextResponse(JSON.stringify(pf), {
headers: { "Content-Type": "application/json" }
});
}
+22
View File
@@ -0,0 +1,22 @@
import { loadPF } from "@/lib/loader";
import { NextRequest, NextResponse } from "next/server";
export async function POST(request: NextRequest, { params }: { params: Promise<{ locale: string }> }) {
try {
const body = await request.json();
const pfIds = body.pfIds as string[];
const { locale } = await params;
if (!Array.isArray(pfIds) || pfIds.some(id => typeof id !== 'string')) {
return NextResponse.json({ error: 'Invalid pfIds' }, { status: 400 });
}
const pfData = await loadPF(pfIds, locale);
return new NextResponse(JSON.stringify(pfData), {
headers: { "Content-Type": "application/json" }
});
} catch {
return NextResponse.json({ error: 'Failed to load pf data' }, { status: 500 });
}
}
+20
View File
@@ -0,0 +1,20 @@
import { NextRequest, NextResponse } from 'next/server'
import { loadRelics } from '@/lib/loader'
export async function GET(
req: NextRequest,
{ params }: { params: Promise<{ id: string, locale: string }> }
) {
const { id, locale } = await params
const relics = await loadRelics([id], locale)
const relic = relics[id]
if (!relic) {
return NextResponse.json({ error: 'Relic not found' }, { status: 404 })
}
return new NextResponse(JSON.stringify(relic), {
headers: { "Content-Type": "application/json" }
});
}
+22
View File
@@ -0,0 +1,22 @@
import { NextRequest, NextResponse } from "next/server";
import { loadRelics } from "@/lib/loader";
export async function POST(request: NextRequest, { params }: { params: Promise<{ locale: string }> }) {
try {
const body = await request.json();
const relicIds = body.relicIds as string[];
const { locale } = await params;
if (!Array.isArray(relicIds) || relicIds.some(id => typeof id !== 'string')) {
return NextResponse.json({ error: 'Invalid relicIds' }, { status: 400 });
}
const relics = await loadRelics(relicIds, locale);
return new NextResponse(JSON.stringify(relics), {
headers: { "Content-Type": "application/json" }
});
} catch {
return NextResponse.json({ error: 'Failed to load relics' }, { status: 500 });
}
}
+13
View File
@@ -0,0 +1,13 @@
import { loadConfigMaze } from "@/lib/loader";
import { NextResponse } from "next/server";
export async function GET() {
try {
const configMaze = await loadConfigMaze();
return new NextResponse(JSON.stringify(configMaze), {
headers: { "Content-Type": "application/json" }
});
} catch {
return NextResponse.json({ error: 'Failed to load config maze' }, { status: 500 });
}
}
+13
View File
@@ -0,0 +1,13 @@
import { loadMainAffix } from "@/lib/loader";
import { NextResponse } from "next/server";
export async function GET() {
try {
const mainAffix = await loadMainAffix();
return new NextResponse(JSON.stringify(mainAffix), {
headers: { "Content-Type": "application/json" }
});
} catch {
return NextResponse.json({ error: 'Failed to load main affix' }, { status: 500 });
}
}
+102
View File
@@ -0,0 +1,102 @@
import { NextRequest, NextResponse } from 'next/server'
import axios from 'axios'
import net from 'net'
function isPrivateHost(hostname: string): boolean {
if (
hostname === 'localhost' ||
hostname.startsWith('127.') ||
hostname.startsWith('10.') ||
hostname.startsWith('192.168.') ||
/^172\.(1[6-9]|2[0-9]|3[0-1])\./.test(hostname)
) {
return true
}
if (net.isIP(hostname)) {
return true
}
return false
}
export async function GET(req: NextRequest) {
try {
const { searchParams } = new URL(req.url)
const targetUrl = searchParams.get("url")
if (!targetUrl) {
return NextResponse.json({ error: "Missing url" }, { status: 400 })
}
const response = await fetch(targetUrl)
if (!response.ok) {
return NextResponse.json({ error: "Failed to fetch image" }, { status: 500 })
}
const buffer = await response.arrayBuffer()
return new NextResponse(buffer, {
headers: {
"Content-Type": response.headers.get("content-type") || "image/png",
"Cache-Control": "public, max-age=3600",
"Access-Control-Allow-Origin": "*",
},
})
} catch (e: unknown) {
return NextResponse.json({ error: (e as Error)?.message }, { status: 500 })
}
}
export async function POST(request: NextRequest) {
try {
const body = await request.json()
const { serverUrl, method, ...payload } = body
if (!serverUrl) {
return NextResponse.json({ error: 'Missing serverUrl' }, { status: 400 })
}
if (!method) {
return NextResponse.json({ error: 'Missing method' }, { status: 400 })
}
let url = serverUrl.trim()
if (!url.startsWith('http://') && !url.startsWith('https://')) {
url = `http://${url}`
}
const parsed = new URL(url)
if (isPrivateHost(parsed.hostname)) {
return NextResponse.json(
{ error: `Connection to private/internal address (${parsed.hostname}) is not allowed` },
{ status: 403 }
)
}
let response
switch (method.toUpperCase()) {
case 'GET':
const queryString = new URLSearchParams(payload as Record<string, string>).toString()
const fullUrl = queryString ? `${url}?${queryString}` : url
response = await axios.get(fullUrl)
break
case 'POST':
response = await axios.post(url, payload)
break
case 'PUT':
response = await axios.put(url, payload)
break
case 'DELETE':
response = await axios.delete(url, { data: payload })
break
default:
return NextResponse.json({ error: `Unsupported method: ${method}` }, { status: 405 })
}
return NextResponse.json(response.data)
} catch (err: unknown) {
return NextResponse.json({ error: (err as Error)?.message || 'Proxy failed' }, { status: 500 })
}
}
+13
View File
@@ -0,0 +1,13 @@
import { loadSubAffix } from "@/lib/loader";
import { NextResponse } from "next/server";
export async function GET() {
try {
const subAffix = await loadSubAffix();
return new NextResponse(JSON.stringify(subAffix), {
headers: { "Content-Type": "application/json" }
});
} catch {
return NextResponse.json({ error: 'Failed to load sub affix' }, { status: 500 });
}
}