Server Error on Prod but not Dev
Unanswered
Arinji posted this in #help-forum
ArinjiOP
All the pages on prod have the error, i checked the logs and it was
TypeError: D.hasOwnProperty is not a function
at (node_modules/safer-buffer/safer.js:13:14)
TypeError: D.hasOwnProperty is not a function
at (node_modules/safer-buffer/safer.js:13:14)
2 Replies
ArinjiOP
Our middleware file (this was updated in the new commit)
import type {NextRequest} from "next/server";
import {NextResponse} from "next/server";
import {validateBetaJWT, validateJWT} from "@/lib/jwtFunctions";
import {isVerified} from "@/lib/emailVerification";
export async function middleware(request: NextRequest) {
const betaToken = request.cookies.get("beta_token")?.value;
const token = request.cookies.get("token")?.value;
if (
request.nextUrl.pathname.startsWith("/api") ||
request.nextUrl.pathname.startsWith("/beta")
) {
return NextResponse.next();
}
if (request.nextUrl.pathname.startsWith("/redirect")) {
const url = request.nextUrl.searchParams.get("url");
try {
if (url) return NextResponse.redirect(url);
else return NextResponse.redirect(`${process.env.WEB_DOMAIN}/`);
} catch (e) {
return NextResponse.redirect(`${process.env.WEB_DOMAIN}/`);
}
}
if (
await validateBetaJWT(betaToken, request.headers.get("x-forwarded-for"))
) {
if (request.nextUrl.pathname.startsWith("/dash")) {
if (token && (await validateJWT(token))) {
if (await isVerified(token)) {
return NextResponse.next();
} else {
return NextResponse.redirect(
`${process.env.WEB_DOMAIN}/verify`
);
}
} else {
const nextPath = encodeURIComponent(request.nextUrl.pathname);
return NextResponse.redirect(
`${process.env.WEB_DOMAIN}/login?next=${nextPath}`
);
}
} else {
return NextResponse.next();
}
} else {
return NextResponse.redirect(`${process.env.WEB_DOMAIN}/beta`);
}
}
export const config = {matcher: "/((?!.*\\.).*)"};ArinjiOP
I found the broken function, and so i added console logs to it.. but it dosent even show up :/ still getting the same error