Next.js Discord

Discord Forum

Next 14, Bcrypt compare function causing build error but only on vercel

Unanswered
Short-tailed Hawk posted this in #help-forum
Open in Discord
Short-tailed HawkOP
When using Bcrypt compare function I get a build error but only at Vercel. Locally it works fine

This is the code currently on /api/login.ts:

import { NextResponse } from 'next/server'; import { compare } from 'bcrypt'; import jwt from "jsonwebtoken"; import cookie from 'cookie' import { loginSchema } from './ZOD'; import { prisma } from '@util/prisma/prisma'; export async function POST(req: Request) { try { const { email, password } = loginSchema.parse(await req.json()) const user = await prisma.users.findUnique({ where: { email } }) const comparePassword = await compare(password, user.password)

The last line is what is causing the error. Then I get this message at Vercel

RangeError: Maximum call stack size exceeded
at RegExp.exec (<anonymous>)
at create (/vercel/path0/node_modules/next/dist/compiled/micromatch/index.js:15:18889)
at create (/vercel/path0/node_modules/next/dist/compiled/micromatch/index.js:15:18918)
at parse.fastpaths (/vercel/path0/node_modules/next/dist/compiled/micromatch/index.js:15:18997)
at picomatch.makeRe (/vercel/path0/node_modules/next/dist/compiled/micromatch/index.js:15:21635)
at picomatch (/vercel/path0/node_modules/next/dist/compiled/micromatch/index.js:15:19637)
at /vercel/path0/node_modules/next/dist/compiled/micromatch/index.js:15:19294
at Array.map (<anonymous>)
at picomatch (/vercel/path0/node_modules/next/dist/compiled/micromatch/index.js:15:19286)
at micromatch.isMatch (/vercel/path0/node_modules/next/dist/compiled/micromatch/index.js:15:1090)
error Command failed with exit code 1.

0 Replies