ghoshnirmalya / nextjs-strapi-boilerplate

:art: Boilerplate for building applications using Strapi and Next.js
https://nextjs-strapi-boilerplate.vercel.app
MIT License
308 stars 82 forks source link

Error when logging in by Google on the frontend #171

Open marcoriesco opened 3 years ago

marcoriesco commented 3 years ago

I'm getting this error, strapi working normally, but I can't log into the strapi through the frontend.

Does anyone go through this?

 OAuthProfile: {
    id: '104265214333844458905',
    email: 'sharkdev.com.br@gmail.com',
    verified_email: true,
    name: 'SHARKDEV SHARKDEV',
    given_name: 'SHARKDEV',
    family_name: 'SHARKDEV',
    picture: 'https://lh3.googleusercontent.com/a-/AOh14Gh4nDcKYkBW5fcxAC4yb4SjgY8zi5QKdNJEL-B7=s96-c',
    locale: 'pt-BR'
  }
}
[next-auth][error][adapter_connection_error] 
https://next-auth.js.org/errors#adapter_connection_error error: password authentication failed for user "strapi"
    at Parser.parseErrorMessage (D:\DEV\App\tmp\teste\frontend\node_modules\pg-protocol\dist\parser.js:278:15)
    at Parser.handlePacket (D:\DEV\App\tmp\teste\frontend\node_modules\pg-protocol\dist\parser.js:126:29)
    at Parser.parse (D:\DEV\App\tmp\teste\frontend\node_modules\pg-protocol\dist\parser.js:39:38)
    at Socket.<anonymous> (D:\DEV\App\tmp\teste\frontend\node_modules\pg-protocol\dist\index.js:10:42)
    at Socket.emit (events.js:315:20)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:271:9)
    at Socket.Readable.push (_stream_readable.js:212:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:186:23) {
  length: 164,
  severity: 'FATAL',
  code: '28P01',
  detail: undefined,
  hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'd:\\pginstaller_13.auto\\postgres.windows-x64\\src\\backend\\libpq\\auth.c',
  line: '334',
  routine: 'auth_failed'
}
[next-auth][error][oauth_callback_handler_error]
https://next-auth.js.org/errors#oauth_callback_handler_error TypeError: Cannot destructure property 'manager' of 'connection' as it is null.
    at Object.<anonymous> (D:\DEV\App\tmp\teste\frontend\node_modules\next-auth\dist\adapters\typeorm\index.js:112:9)
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (D:\DEV\App\tmp\teste\frontend\node_modules\next-auth\dist\adapters\typeorm\index.js:26:103)
    at _next (D:\DEV\App\tmp\teste\frontend\node_modules\next-auth\dist\adapters\typeorm\index.js:28:194)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
ghoshnirmalya commented 3 years ago

@marcoriesco I believe that this issue is similar to https://github.com/ghoshnirmalya/nextjs-strapi-boilerplate/issues/4. Please let me know if the discussion in that issue helps you. I'll keep this open for the time being.

rvanderfeer commented 3 years ago

I was able to resolve by examining #4 - for me the issue was that I had a local postgres instance running, and the docker container's port mapping (5432:5432) was masked by this instance as it uses the default port. This causes the frontend to connect to the local postgres instance, where the strapi user & db don't exist.

Either stopping the local postgres or changing the external port in frontend/.env and backend/docker-compose.yml 's db section will resolve (gotcha here was not to change the internal DATABASE_PORT used in the backend service).