Postgres connection problems after fresh repository cloned
See original GitHub issueHello, first of all, thank you that you have decided to fill in this lack of a suitable tool for combining strapi authentication with next-auth authorization.
I have such a problem. Freshly cloned from GitHub, my google auth data in .env and when I try to create an account or sign in then I got the error: “Try signing with a different account.” (logs from nextjs on the bottom)
Google?NextJS? can’t connect to database, but I don’t know why? I didn’t chance anything… in env: NEXT_PUBLIC_DATABASE_URL=postgres://strapi:strapi@localhost:5432/strapi
by the way… Can you explain how this is working? Does next-auth connect directly to the database? Completely disregarding the Strapi? It should working identical without Strapi?
`event - build page: /api/auth/[…nextauth]
wait - compiling… event - compiled successfully [next-auth][debug][profile_data] { id: ‘xxx’, email: ‘xxx@gmail.com’, verified_email: true, name: ‘xxx’, given_name: ‘xxx’, family_name: ‘xxx’, picture: ‘https://xxx.x/photo.jpg’, locale: ‘xx’ } [next-auth][debug][oauth_callback_response] { profile: { name: ‘xxx’, email: ‘xxx@gmail.com’, image: ‘https://xxxx.x/photo.jpg’ }, account: { provider: ‘google’, type: ‘oauth’, id: ‘xxx’, refreshToken: undefined, accessToken: ‘xxx.xxxx.xxx’, accessTokenExpires: null }, OAuthProfile: { id: ‘xxxx’, email: ‘xxx@gmail.com’, verified_email: true, name: ‘xxx’, given_name: ‘xxx’, family_name: ‘xxx’, picture: ‘https://xxx.x/photo.jpg’, locale: ‘xx’ } } [next-auth][error][adapter_connection_error] error: role “strapi” does not exist at Parser.parseErrorMessage (/Users/xxxx/test-env/nextjs-strapi-boilerplate/frontend/node_modules/pg-protocol/dist/parser.js:278:15) at Parser.handlePacket (/Users/xxx/test-env/nextjs-strapi-boilerplate/frontend/node_modules/pg-protocol/dist/parser.js:126:29) at Parser.parse (/Users/xxx/test-env/nextjs-strapi-boilerplate/frontend/node_modules/pg-protocol/dist/parser.js:39:38) at Socket.<anonymous> (/Users/xxx/test-env/nextjs-strapi-boilerplate/frontend/node_modules/pg-protocol/dist/index.js:8:42) at Socket.emit (events.js:314:20) at addChunk (_stream_readable.js:303:12) at readableAddChunk (_stream_readable.js:279:9) at Socket.Readable.push (_stream_readable.js:218:10) at TCP.onStreamRead (internal/stream_base_commons.js:188:23) { length: 98, severity: ‘FATAL’, code: ‘28000’, detail: undefined, hint: undefined, position: undefined, internalPosition: undefined, internalQuery: undefined, where: undefined, schema: undefined, table: undefined, column: undefined, dataType: undefined, constraint: undefined, file: ‘miscinit.c’, line: ‘607’, routine: ‘InitializeSessionUserId’ } https://next-auth.js.org/errors#adapter_connection_error [next-auth][error][oauth_callback_handler_error] TypeError: Cannot destructure property ‘manager’ of ‘connection’ as it is null. at Object.<anonymous> (/Users/xxx/test-env/nextjs-strapi-boilerplate/frontend/node_modules/next-auth/dist/adapters/typeorm/index.js:102:9) at Generator.next (<anonymous>) at asyncGeneratorStep (/Users/xxxx/test-env/nextjs-strapi-boilerplate/frontend/node_modules/next-auth/dist/adapters/typeorm/index.js:28:103) at _next (/Users/xxxx/test-env/nextjs-strapi-boilerplate/frontend/node_modules/next-auth/dist/adapters/typeorm/index.js:30:194) at processTicksAndRejections (internal/process/task_queues.js:93:5) https://next-auth.js.org/errors#oauth_callback_handler_error`
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:15 (5 by maintainers)
@ghoshnirmalya @sebacampos Thanks for help. Thats look like working fine now. I have cloned last version again, follow all steps and is working so I close the issue as it no longer an issue. Thanks one more time.
@oskar-gmerek any console log when you get that error?
Since the error is “Error: Invalid token” I would suggest:
console.log('token: ', token)
just after this line , so in line 13, to understand what is happening. I’m guessing that theauthorization: Bearer ${token}
on line 21 is not being sent correctlyJWT_SECRET
env var, which might be causing conflict on encoding/decoding the jwt maybe(?)