This commit is contained in:
Atridad Lahiji 2023-08-17 20:58:19 -06:00 committed by atridadl
parent 482189896e
commit 1929208af6
No known key found for this signature in database
4 changed files with 3 additions and 9 deletions

View file

@ -6,7 +6,6 @@ export default authMiddleware({
publicRoutes: ["/", "/api/public/(.*)"],
afterAuth: async (auth, req) => {
if (!auth.userId && auth.isPublicRoute) {
console.log("1");
return NextResponse.next();
}
@ -14,9 +13,7 @@ export default authMiddleware({
req.nextUrl.pathname.includes("/api/webhooks") ||
req.nextUrl.pathname.includes("/api/private")
) {
console.log("2");
const isValid = await validateRequest(req);
console.log("Is Valid?: ", isValid);
if (isValid) {
return NextResponse.next();
} else {
@ -24,9 +21,7 @@ export default authMiddleware({
}
}
if (!auth.userId && !auth.isPublicRoute) {
console.log(req.nextUrl);
console.log("3");
return redirectToSignIn({ returnBackUrl: req.url });
redirectToSignIn({ returnBackUrl: req.url });
}
},
});

View file

@ -5,7 +5,7 @@ export const config = {
regions: ["pdx1"],
};
export default async function handler() {
export default function handler() {
return NextResponse.json(
{ message: "Private Pong!" },
{ status: 200, statusText: "SUCCESS" }

View file

@ -5,7 +5,7 @@ export const config = {
regions: ["pdx1"],
};
export default async function handler() {
export default function handler() {
return NextResponse.json(
{ message: "Public Pong!" },
{ status: 200, statusText: "SUCCESS" }

View file

@ -1,5 +1,4 @@
import type { NextApiRequest, NextApiResponse } from "next";
import { validateRequest } from "~/server/unkey";
import {
onUserCreatedHandler,
onUserDeletedHandler,