question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Postgres connection problems after fresh repository cloned

See original GitHub issue

Hello, 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:15 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
oskar-gmerekcommented, Aug 31, 2020

@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.

1reaction
sebacamposcommented, Aug 31, 2020

@ghoshnirmalya I cloned the repository with the new version, followed exactly as in the directions and …

Unfortunately, the same error was popping up. Using the @sebacampos hint, I changed the port for postgres into docker-compose and .env

Another error has occurred. Here @sebacampos comes in handy again with his PR #6 , after removing ‘/graphql’ from NEXT_PUBLIC_API_URL in .env I can log in, but is still not working as expected. Im logged, but instead of content I got “Error: Invalid token” Its probably because an user isn’t created in strapi. I guess somewhere is missed ‘/graphql’ in path after fixing like that in .env for previous error

@oskar-gmerek any console log when you get that error?

Since the error is “Error: Invalid token” I would suggest:

  • add a console.log('token: ', token) just after this line , so in line 13, to understand what is happening. I’m guessing that the authorization: Bearer ${token} on line 21 is not being sent correctly
  • Verify the token on jwt.io Debugger.
  • Verify if you have any JWT_SECRET env var, which might be causing conflict on encoding/decoding the jwt maybe(?)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Working with Git - PostgreSQL wiki
One option while requesting a project at git.postgresql.org is to have a clone of the main postgresql repository. That is very nice feature,...
Read more >
Can't run cloned repository - Stack Overflow
I have a mac, and I read somewhere that PostgreSQL comes automatically on macs, is that not true? – Alicia T. Glenn. Nov...
Read more >
Troubleshooting Geo - GitLab Docs
Can connect to the primary node ... yes HTTP/HTTPS repository cloning is enabled ... If a fresh git clone of a repository on...
Read more >
Disaster Recovery and Cloning - Crunchy Data
The above is all you need to do to clone a Postgres cluster! PGO will work on creating a copy of your data...
Read more >
Clone instances | Cloud SQL for PostgreSQL
The new instance will have the same settings such as database flags, connectivity options, machine type, and storage and memory settings. Are replicas...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found