小编Gle*_*duk的帖子

NestJS | 护照:类型错误:无法读取未定义的属性(读取“登录”)

情况:

  • 在 Nest 和 grapqhql 中开发 api
  • 在一台笔记本电脑上工作,一切正常
  • 然后在其他笔记本电脑上克隆我的存储库,安装依赖项,创建一个新的本地数据库。
  • 应用程序正在构建,没有错误
  • 当在浏览器中关注 localhost:4000 打开 graphql Playground 时,我收到 500 错误结束下一条消息:
    ERROR [ExceptionsHandler] Cannot read properties of undefined (reading 'logIn')
    TypeError: Cannot read properties of undefined (reading 'logIn')
        at authenticate (/home/gleb/Projects/artwine-api/node_modules/passport/lib/middleware/authenticate.js:96:21)
        at /home/gleb/Projects/artwine-api/node_modules/@nestjs/passport/dist/auth.guard.js:91:3
        at new Promise (<anonymous>)
        at /home/gleb/Projects/artwine-api/node_modules/@nestjs/passport/dist/auth.guard.js:83:83
        at JWTAccessAuthGuard.<anonymous> (/home/gleb/Projects/artwine-api/node_modules/@nestjs/passport/dist/auth.guard.js:49:36)
        at Generator.next (<anonymous>)
        at fulfilled (/home/gleb/Projects/artwine-api/node_modules/@nestjs/passport/dist/auth.guard.js:17:58)
        at processTicksAndRejections (node:internal/process/task_queues:96:5)
    
    Run Code Online (Sandbox Code Playgroud)

捕获错误的护照库函数的代码:

return function authenticate(req, res, next) {
    req.login =
    req.logIn = req.logIn || IncomingMessageExt.logIn;
    req.logout =
    req.logOut = req.logOut || IncomingMessageExt.logOut;
    req.isAuthenticated …
Run Code Online (Sandbox Code Playgroud)

nest passport.js

18
推荐指数
3
解决办法
1万
查看次数

NestJS =&gt; PostgresQL:错误:GetAddrInfo EAI_AGAIN postgres at GetAddrInfoReqWrap.onlookup

我一直在开发一个连接到本地 Postgres 数据库的 NestJS-GraphQL 应用程序。一切都工作正常,直到 Ubuntu 20.04 重新安装。

在使用项目克隆存储库、安装 Postgres 并使用yarn start:dev构建应用程序后,我可以看到这个奇怪的错误:

[Nest] 21577  - 02/05/2022, 2:51:10 PM   ERROR [TypeOrmModule] Unable to connect to the database. Retrying (1)...
Error: getaddrinfo EAI_AGAIN postgres
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:71:26)
Run Code Online (Sandbox Code Playgroud)

Postgres 正在运行:

hleb@hleb:~$ psql artwine postgres
psql (14.1 (Ubuntu 14.1-2.pgdg20.04+1))
Type "help" for help.

artwine=# 
Run Code Online (Sandbox Code Playgroud)

/etc/postgresql/14/main/pg_hba.conf

# Database administrative login by Unix domain socket
local   all             postgres                                trust

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket …
Run Code Online (Sandbox Code Playgroud)

postgresql nestjs

4
推荐指数
1
解决办法
8669
查看次数

标签 统计

nest ×1

nestjs ×1

passport.js ×1

postgresql ×1