From 8ab35b3c34664500830a4b9cc3eff7bd02c4c9c1 Mon Sep 17 00:00:00 2001 From: Haris Razis Date: Mon, 21 Dec 2020 19:02:10 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Change=20server=20port=20to=2080?= =?UTF-8?q?00?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Had issues with frontend on 6000 --- client/config/keys.js | 2 +- docker-compose.yml | 2 +- server/index.js | 16 ++++++++++------ web/src/store/index.ts | 5 ++--- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/client/config/keys.js b/client/config/keys.js index b4c4110..b7702b7 100644 --- a/client/config/keys.js +++ b/client/config/keys.js @@ -1,3 +1,3 @@ module.exports = { - server_url: 'http://backend:6000' + server_url: 'http://backend:8000' } \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 7b379c7..f37ee05 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -37,7 +37,7 @@ services: max_attempts: 3 window: 120s ports: - - "6000:6000" + - "8000:8000" networks: - backend - frontend diff --git a/server/index.js b/server/index.js index 8e780a8..5fe5445 100644 --- a/server/index.js +++ b/server/index.js @@ -1,16 +1,19 @@ const app = require('express')() const server = require('http').createServer(app); const bodyParser = require('body-parser'); -const passport = require('./services/passport'); const chalk = require('chalk') const cors = require('cors') + require('./services/socket')(server); +require('./connections/mongo_conn'); const dataRoute = require('./routes/data') -const authRoute = require('./routes/data') +const authRoute = require('./routes/auth') + +const passport = require('./services/passport'); const {session_secret} = require('./config/keys'); -//allow for all requests for development. +//allow all requests for development. app.use(cors()) app.use(bodyParser.urlencoded({ @@ -28,8 +31,9 @@ app.use(passport.initialize(undefined)); app.use(passport.session(undefined)); app.use(dataRoute) -app.use('/api', authRoute) +app.use(authRoute) -server.listen(6000, () => { - console.log(chalk.green.bold('Server listening on port 6000!')); +const PORT = process.env.PORT || 8000; +server.listen(PORT, () => { + console.log(chalk.green.bold(`Server listening on port ${PORT}!`)); }); diff --git a/web/src/store/index.ts b/web/src/store/index.ts index 834c645..acab2cd 100644 --- a/web/src/store/index.ts +++ b/web/src/store/index.ts @@ -22,9 +22,9 @@ export default createStore({ actions: { login({commit}, user: { username: string, password: string }) { return new Promise((resolve, reject) => { - axios({url: 'http://backend:6000/api/auth/login', data: {user}, method: 'POST'}) + axios({url: 'http://localhost:8000/auth/login', data: {user}, method: 'GET'}) .then((resp: AxiosResponse) => { - commit("auth_success", user.username); + commit("auth_success", user); resolve(resp) }) .catch((err: Error) => { @@ -35,7 +35,6 @@ export default createStore({ }, logout({commit}) { return new Promise((resolve, reject) => { - let user = null; commit("logout"); resolve() })