From 05f9c9fce08e3e6e3d1d5d892e738bb19def03f1 Mon Sep 17 00:00:00 2001 From: Augusto Date: Sat, 2 Mar 2024 13:59:56 +0100 Subject: [PATCH 1/2] Adding --- gatewayservice/gateway-service.js | 4 ++-- users/authservice/auth-service.js | 2 +- users/userservice/user-service.js | 2 +- webapp/src/components/AddUser.js | 2 +- webapp/src/components/Login.js | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gatewayservice/gateway-service.js b/gatewayservice/gateway-service.js index 6527df61..88b84c8f 100644 --- a/gatewayservice/gateway-service.js +++ b/gatewayservice/gateway-service.js @@ -6,8 +6,8 @@ const promBundle = require('express-prom-bundle'); const app = express(); const port = 8000; -const authServiceUrl = process.env.AUTH_SERVICE_URL ; -const userServiceUrl = process.env.USER_SERVICE_URL ; +const authServiceUrl = process.env.AUTH_SERVICE_URL || 'http://localhost:8002'; +const userServiceUrl = process.env.USER_SERVICE_URL || 'http://localhost:8001'; app.use(cors()); app.use(express.json()); diff --git a/users/authservice/auth-service.js b/users/authservice/auth-service.js index cefbdf8e..9764f088 100644 --- a/users/authservice/auth-service.js +++ b/users/authservice/auth-service.js @@ -11,7 +11,7 @@ const port = 8002; app.use(express.json()); // Connect to MongoDB -const mongoUri = process.env.MONGODB_URI; +const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/userdb'; mongoose.connect(mongoUri); // Function to validate required fields in the request body diff --git a/users/userservice/user-service.js b/users/userservice/user-service.js index b5cd7cb1..be958427 100644 --- a/users/userservice/user-service.js +++ b/users/userservice/user-service.js @@ -12,7 +12,7 @@ const port = 8001; app.use(bodyParser.json()); // Connect to MongoDB -const mongoUri = process.env.MONGODB_URI; +const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/userdb'; mongoose.connect(mongoUri); diff --git a/webapp/src/components/AddUser.js b/webapp/src/components/AddUser.js index ddbcb070..73e3ce26 100644 --- a/webapp/src/components/AddUser.js +++ b/webapp/src/components/AddUser.js @@ -3,7 +3,7 @@ import React, { useState } from 'react'; import axios from 'axios'; import { Container, Typography, TextField, Button, Snackbar } from '@mui/material'; -const apiEndpoint = process.env.REACT_APP_API_ENDPOINT; +const apiEndpoint = process.env.REACT_APP_API_ENDPOINT||'http://localhost:8000'; const AddUser = () => { const [username, setUsername] = useState(''); diff --git a/webapp/src/components/Login.js b/webapp/src/components/Login.js index 4397a52b..cb869feb 100644 --- a/webapp/src/components/Login.js +++ b/webapp/src/components/Login.js @@ -11,7 +11,7 @@ const Login = () => { const [createdAt, setCreatedAt] = useState(''); const [openSnackbar, setOpenSnackbar] = useState(false); - const apiEndpoint = process.env.REACT_APP_API_ENDPOINT; + const apiEndpoint = process.env.REACT_APP_API_ENDPOINT||'http://localhost:8000'; const loginUser = async () => { try { From d357b6ca8a618bf675769eef5689df23c0746098 Mon Sep 17 00:00:00 2001 From: Augusto Date: Sat, 2 Mar 2024 14:13:05 +0100 Subject: [PATCH 2/2] Removing urls in AddUser and Login.js --- webapp/src/components/AddUser.js | 2 +- webapp/src/components/Login.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/src/components/AddUser.js b/webapp/src/components/AddUser.js index 73e3ce26..ddbcb070 100644 --- a/webapp/src/components/AddUser.js +++ b/webapp/src/components/AddUser.js @@ -3,7 +3,7 @@ import React, { useState } from 'react'; import axios from 'axios'; import { Container, Typography, TextField, Button, Snackbar } from '@mui/material'; -const apiEndpoint = process.env.REACT_APP_API_ENDPOINT||'http://localhost:8000'; +const apiEndpoint = process.env.REACT_APP_API_ENDPOINT; const AddUser = () => { const [username, setUsername] = useState(''); diff --git a/webapp/src/components/Login.js b/webapp/src/components/Login.js index cb869feb..4397a52b 100644 --- a/webapp/src/components/Login.js +++ b/webapp/src/components/Login.js @@ -11,7 +11,7 @@ const Login = () => { const [createdAt, setCreatedAt] = useState(''); const [openSnackbar, setOpenSnackbar] = useState(false); - const apiEndpoint = process.env.REACT_APP_API_ENDPOINT||'http://localhost:8000'; + const apiEndpoint = process.env.REACT_APP_API_ENDPOINT; const loginUser = async () => { try {