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:
saravanakumardb1 2026-03-21 20:12:24 -07:00
parent 633fe855bf
commit 7b6aa53d68
3 changed files with 9 additions and 3 deletions

View File

@ -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',

View File

@ -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);
}

View File

@ -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);
} }