я получаю следующую ошибку при выполнении docker-compose.Приложение работает, но не может отправлять / отправлять запросы API.Экспресс-сервер использует порт 5000.
] [HPM] Произошла ошибка при попытке прокси-запроса / api / users / user от localhost: от 3000 до http://localhost:5000/ (ECONNREFUSED) (https://nodejs.org/api/errors.html#errors_common_system_errors)
Несмотря на настройку реактивного прокси, ошибка сохраняется.
setupProxy.js
const proxy = require('http-proxy-middleware');
module.exports = function(app) {
// app.use(proxy('/auth/github', { target: 'http://localhost:3000/' }))
app.use(proxy('/api/users/auth/github', { target: 'http://localhost:5000/' }))
app.use(proxy('/api/users/', { target: 'http://localhost:5000/' }))
app.use(proxy('/api/posts/', { target: 'http://localhost:5000/' }))
}
Dockerfile
FROM node:8.10.0-alpine
EXPOSE 3000
COPY . /home/app
WORKDIR /home/app
RUN npm install
CMD ["npm", "start"]
docker-compose.yml
# docker-compose.yml
version: "3"
services:
app:
build: .
depends_on:
- postgres
ports:
- "3000:3000"
- "9229:9229"
postgres:
image: postgres:9.6.8-alpine
expose:
- 5432
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: user
POSTGRES_DB: db
package.json
{
"name": "sequelize-demo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"client": "cd ./client && npm start",
"server": "nodemon app.js --ignore client",
"build": "echo 'hello build'",
"start": "concurrently --kill-others \"npm run server\" \"npm run client\""
},
"author": "",
"license": "ISC",
"dependencies": {
"async": "^2.6.1",
"bcrypt": "^3.0.3",
"body-parser": "^1.18.3",
"concurrently": "^4.1.0",
"cookie-parser": "^1.4.3",
"cookie-session": "^2.0.0-beta.3",
"cors": "^2.8.5",
"crypto": "^1.0.1",
"dotenv": "^6.2.0",
"express": "^4.16.4",
"express-flash": "0.0.2",
"express-session": "^1.15.6",
"jsonwebtoken": "^8.4.0",
"morgan": "^1.9.1",
"nodemailer": "^5.1.1",
"nodemon": "^1.18.9",
"passport": "^0.4.0",
"passport-github": "^1.1.0",
"passport-github2": "^0.1.11",
"passport-jwt": "^4.0.0",
"passport-local": "^1.0.0",
"pg": "^7.8.0",
"pg-hstore": "^2.3.2",
"sequelize": "^4.42.0"
}
}