fix(admin-web): proxy route path mismatches + missing HTTP methods
- maintenance: fix path /api/maintenance → /api/settings/maintenance - maintenance: replace PATCH with PUT + add DELETE (matches backend API) - ip-rules: fix path /api/ip-rules → /api/ratelimit/ip-rules - jobs: add missing PUT handler for job updates
This commit is contained in:
parent
633fe855bf
commit
7b6aa53d68
@ -13,7 +13,7 @@ async function proxy(req: NextRequest, { params }: { params: Promise<{ path: str
|
|||||||
const caller = await getCurrentUser(req.headers.get('authorization'));
|
const caller = await getCurrentUser(req.headers.get('authorization'));
|
||||||
if (!caller) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
if (!caller) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
||||||
const { path } = await params;
|
const { path } = await params;
|
||||||
const targetPath = `/api/ip-rules/${path.join('/')}`;
|
const targetPath = `/api/ratelimit/ip-rules/${path.join('/')}`;
|
||||||
const qs = new URL(req.url).search;
|
const qs = new URL(req.url).search;
|
||||||
const headers: Record<string, string> = {
|
const headers: Record<string, string> = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|||||||
@ -38,3 +38,6 @@ export async function GET(req: NextRequest, ctx: { params: Promise<{ path: strin
|
|||||||
export async function POST(req: NextRequest, ctx: { params: Promise<{ path: string[] }> }) {
|
export async function POST(req: NextRequest, ctx: { params: Promise<{ path: string[] }> }) {
|
||||||
return proxy(req, ctx);
|
return proxy(req, ctx);
|
||||||
}
|
}
|
||||||
|
export async function PUT(req: NextRequest, ctx: { params: Promise<{ path: string[] }> }) {
|
||||||
|
return proxy(req, ctx);
|
||||||
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ async function proxy(req: NextRequest, { params }: { params: Promise<{ path: str
|
|||||||
const caller = await getCurrentUser(req.headers.get('authorization'));
|
const caller = await getCurrentUser(req.headers.get('authorization'));
|
||||||
if (!caller) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
if (!caller) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
||||||
const { path } = await params;
|
const { path } = await params;
|
||||||
const targetPath = `/api/maintenance/${path.join('/')}`;
|
const targetPath = `/api/settings/maintenance/${path.join('/')}`;
|
||||||
const qs = new URL(req.url).search;
|
const qs = new URL(req.url).search;
|
||||||
const headers: Record<string, string> = {
|
const headers: Record<string, string> = {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -38,6 +38,9 @@ export async function GET(req: NextRequest, ctx: { params: Promise<{ path: strin
|
|||||||
export async function POST(req: NextRequest, ctx: { params: Promise<{ path: string[] }> }) {
|
export async function POST(req: NextRequest, ctx: { params: Promise<{ path: string[] }> }) {
|
||||||
return proxy(req, ctx);
|
return proxy(req, ctx);
|
||||||
}
|
}
|
||||||
export async function PATCH(req: NextRequest, ctx: { params: Promise<{ path: string[] }> }) {
|
export async function PUT(req: NextRequest, ctx: { params: Promise<{ path: string[] }> }) {
|
||||||
|
return proxy(req, ctx);
|
||||||
|
}
|
||||||
|
export async function DELETE(req: NextRequest, ctx: { params: Promise<{ path: string[] }> }) {
|
||||||
return proxy(req, ctx);
|
return proxy(req, ctx);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user