diff --git a/gatewayservice/Dockerfile b/gatewayservice/Dockerfile index 52d44b2..6c34043 100644 --- a/gatewayservice/Dockerfile +++ b/gatewayservice/Dockerfile @@ -15,5 +15,3 @@ COPY . . # Define the command to run your app CMD ["node", "gateway-service.js"] - -EXPOSE 8000 diff --git a/gatewayservice/gateway-service.js b/gatewayservice/gateway-service.js index bb3a7c4..ef8f165 100644 --- a/gatewayservice/gateway-service.js +++ b/gatewayservice/gateway-service.js @@ -27,6 +27,7 @@ app.post('/login', async (req, res) => { const authResponse = await axios.post(userServiceUrl + '/auth/login', req.body); res.json(authResponse.data); } catch (error) { + res.status(error.response.status).json({ error: error.response.data.error }); console.error(error); } }); @@ -37,6 +38,7 @@ app.post('/adduser', async (req, res) => { const userResponse = await axios.post(userServiceUrl + '/user/adduser', req.body); res.json(userResponse.data); } catch (error) { + res.status(error.response.status).json({ error: error.response.data.error }); console.error(error); } }); @@ -47,6 +49,7 @@ app.post('/edituser', async (req, res) => { const userResponse = await axios.post(userServiceUrl + '/user/edituser', req.body); res.json(userResponse.data); } catch (error) { + res.status(error.response.status).json({ error: error.response.data.error }); console.error(error); } }); @@ -58,6 +61,7 @@ app.get('/WikiData/GetCapitalsQuestions', async (_req, res) => { const wikiResponse = await axios.get(wikidataServiceUrl + '/WikiData/GetCapitalsQuestions'); res.json(wikiResponse.data); } catch (error) { + res.status(error.response.status).json({ error: error.response.data.error }); console.error(error); } }); diff --git a/users/Dockerfile b/users/Dockerfile index a85b2ba..4667f11 100644 --- a/users/Dockerfile +++ b/users/Dockerfile @@ -19,5 +19,3 @@ EXPOSE 8002 # Define the command to run your app CMD ["node", "index.js"] -EXPOSE 8002 - diff --git a/webapp/src/services/auth-service.ts b/webapp/src/services/auth-service.ts index a06f4e5..db47d56 100644 --- a/webapp/src/services/auth-service.ts +++ b/webapp/src/services/auth-service.ts @@ -23,7 +23,7 @@ export const loginWithToken = () => { export const login = async (username: string, password: string)=> { try { - const response = await axios.post(API_URL + "/login", { username, password }); + const response = await axios.post(`${API_URL}/login`, { username, password }); //const response = await axios.post("http://localhost:8002/auth/login", { username, password }); const token = response.data.token; console.log('token:', token); @@ -38,7 +38,7 @@ export const login = async (username: string, password: string)=> { export const register = async (email:string, username: string, password: string) => { try { - const response = await axios.post(API_URL + "/adduser", { username, password, email }); + const response = await axios.post(`${API_URL}/adduser`, { username, password, email }); console.log('response:', response); const name = response.data; return name;