Я пытаюсь запустить сервер apollo, который подключается к postgres внутри контейнера докера, но я не могу аутентифицироваться даже с правильными учетными данными.Я уже остановил и удалил свой том, а также перезапустил докер.
Это мой index.js
const { ApolloServer } = require('apollo-server-express')
const { Client } = require('pg')
const { postgres: { config } } = require('./config')
const cors = require('cors')
const express = require('express')
const typeDefs = require('./typeDefs')
const importResolvers = require('./resolvers')
const client = new Client(config)
const db = client.connect()
const resolvers = importResolvers(db)
const app = express()
const context = { db }
app.use(cors())
const server = new ApolloServer({
typeDefs,
resolvers,
context
})
server.applyMiddleware({ app })
app.listen({ port: 4000 }, () => {
console.log(`? Server running at http://localhost:4000`)
})
мой докер-compose.yml
version: '3'
services:
postgres:
image: postgres
restart: always
ports:
- '5432:5432'
environment:
POSTGRES_DB: default
POSTGRES_USER: root
POSTGRES_PASSWORD: 2107
volumes:
- ./db/init.sql:/docker-entrypoint-initdb.d/init.sql
- postgres:/var/lib/postgresql/data
volumes:
postgres:
my config.js
PG_USER=root
PG_HOST=localhost
PG_DATABASE=default
PG_PASSWORD=2107
PG_PORT=5432
и, наконец, ошибка:
(node:94021) UnhandledPromiseRejectionWarning: error: password authentication failed for user "root"
at Connection.parseE (/Users/evellynmontalvao/projects/from-rest-to-graphql/node_modules/pg/lib/connection.js:602:11)
at Connection.parseMessage (/Users/evellynmontalvao/projects/from-rest-to-graphql/node_modules/pg/lib/connection.js:399:19)
at Socket.<anonymous> (/Users/evellynmontalvao/projects/from-rest-to-graphql/node_modules/pg/lib/connection.js:121:22)
at Socket.emit (events.js:180:13)
at addChunk (_stream_readable.js:274:12)
at readableAddChunk (_stream_readable.js:261:11)
at Socket.Readable.push (_stream_readable.js:218:10)
at TCP.onread (net.js:581:20)