0

在 Remix 的 Jokes App 教程中,我在 session.server.ts 中获取用户的过程中出错。

我认为这个错误是关于 Prisma 的,但我不知道如何解决它。

网址:https ://remix.run/docs/en/v1/tutorials/jokes#authentication

TypeError: Cannot read properties of undefined (reading 'findUnique')
    at login (/usr/src/app/remix-jokes/build/index.js:700:30)
    at action2 (/usr/src/app/remix-jokes/build/index.js:751:26)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Object.callRouteAction (/usr/src/app/remix-jokes/node_modules/@remix-run/server-runtime/data.js:36:14)
    at async renderDocumentRequest (/usr/src/app/remix-jokes/node_modules/@remix-run/server-runtime/server.js:216:24)
    at async requestHandler (/usr/src/app/remix-jokes/node_modules/@remix-run/server-runtime/server.js:55:20)
    at async /usr/src/app/remix-jokes/node_modules/@remix-run/express/server.js:45:22

它似乎发生在findUnique以下代码的调用中。

export async function login({
  username,
  password
}: LoginForm) {
  const user = await db.user.findUnique({
    where: { username }
  });
  if (!user) return null;

  const isCorrectPassword = await bcrypt.compare(
    password,
    user.passwordHash
  );
  if (!isCorrectPassword) return null;

  return user;
}
4

1 回答 1

1

我重新启动了 Docker 容器并解决了问题。谢谢你。

于 2022-02-03T02:48:24.097 回答