minor bugfixes

This commit is contained in:
Ludwig Lehnert
2026-03-28 09:10:40 +01:00
parent 48bfe69d09
commit ee72edecb1
7 changed files with 94 additions and 22 deletions

View File

@@ -107,8 +107,12 @@ function expectsHtml(request) {
function errorResponse(request, message, status = 400) {
if (expectsHtml(request)) {
const target = new URL(dashboardHref({ error: message }), request.url);
return NextResponse.redirect(target, { status: 303 });
return new NextResponse(null, {
status: 303,
headers: {
location: dashboardHref({ error: message }),
},
});
}
return NextResponse.json({ ok: false, error: message }, { status });
@@ -117,8 +121,12 @@ function errorResponse(request, message, status = 400) {
function successResponse(request, message) {
const redirectPath = dashboardHref({ success: message });
if (expectsHtml(request)) {
const target = new URL(redirectPath, request.url);
return NextResponse.redirect(target, { status: 303 });
return new NextResponse(null, {
status: 303,
headers: {
location: redirectPath,
},
});
}
return NextResponse.json({ ok: true, redirect: redirectPath });