minor bugfixes
This commit is contained in:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user