diff --git a/docker-compose.yml b/docker-compose.yml index 4683cd54..46f9843d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -109,6 +109,8 @@ services: - gatewayservice ports: - "3000:3000" + environment: + GATEWAY_SERVICE_URL: http://gatewayservice:8000 #volumes: #- ./webapp:/app diff --git a/webapp/src/components/Game.jsx b/webapp/src/components/Game.jsx index 6afa2136..88456bf7 100644 --- a/webapp/src/components/Game.jsx +++ b/webapp/src/components/Game.jsx @@ -7,6 +7,8 @@ import { PostGame } from './PostGame' const N_QUESTIONS = 10 const MAX_TIME = 600; +const gatewayUrl=process.env.GATEWAY_SERVICE_URL||"http://localhost:8000" + const Question = ({ goTo, setGameFinished }) => { const [question, setQuestion] = useState(''); @@ -43,9 +45,8 @@ const Question = ({ goTo, setGameFinished }) => { const fetchQuestion = async () => { try { - const response = await fetch('http://localhost:8000/api/questions/create', { - method: 'GET', - mode: 'cors', + const response = await fetch(`${gatewayUrl}/api/questions/create`, { + method: 'GET' }); const data = await response.json();