Skip to content

Commit

Permalink
fix: Use NextResponse.redirect()
Browse files Browse the repository at this point in the history
  • Loading branch information
rexmagnusdavid committed Feb 21, 2024
1 parent 12bf6c9 commit 6dd7e5a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions app/api/submission/create/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import prisma from "@/lib/prisma";
import { duplicateEntry, filterBodyAndValidate, getUserFromRequest, missingFields, redirect, wrongMethod } from "@/lib/server";
import { duplicateEntry, filterBodyAndValidate, getUserFromRequest, missingFields, wrongMethod } from "@/lib/server";
import { PrismaClientKnownRequestError } from "@prisma/client/runtime/library";
import { NextResponse } from "next/server";

Expand All @@ -19,11 +19,11 @@ export async function POST(req: Request) {

const user = await getUserFromRequest();
if (!user) {
return redirect("/api/auth/signin");
return NextResponse.redirect(new URL("/api/auth/signin", req.url));
}

if (!user.teamId) {
return redirect("/dashboard/team/create")
return NextResponse.redirect(new URL("/dashboard/team/create", req.url));
}

const { tracks, ...restOfBody } = body;
Expand Down
7 changes: 3 additions & 4 deletions app/api/submission/edit/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
filterBody,
getUserFromRequest,
missingFields,
redirect,
wrongMethod,
} from "@/lib/server";
import { NextResponse } from 'next/server';
Expand All @@ -19,7 +18,7 @@ export async function POST(req: Request) {

const user = await getUserFromRequest();
if (!user) {
return redirect("/api/auth/signin");
return NextResponse.redirect(new URL("/api/auth/signin", req.url));
}

const json = await req.json();
Expand All @@ -30,11 +29,11 @@ export async function POST(req: Request) {
}

if (!user.team || !user.teamId) {
return redirect("/dashboard/team/create");
return NextResponse.redirect(new URL("/dashboard/team/create", req.url));
}

if (!user.team.submission) {
return redirect("/dashboard/submission/create");
return NextResponse.redirect(new URL("/dashboard/submission/create", req.url));
}

if (body.media) {
Expand Down

1 comment on commit 6dd7e5a

@vercel
Copy link

@vercel vercel bot commented on 6dd7e5a Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

website – ./

website-atomhacks.vercel.app
atomhacks.org
website-git-main-atomhacks.vercel.app

Please sign in to comment.