Skip to content

Commit 1f0bcce

Browse files
committed
Make frontend work in docker
1 parent 96caf0a commit 1f0bcce

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ services:
2020
working_dir: /myapp/frontend
2121
volumes:
2222
- ./frontend:/myapp/frontend
23-
command: "yarn start"
23+
command: "yarn dev"
2424
depends_on:
2525
- backend
2626
yaichi:

frontend/src/App.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import React from 'react';
22
import './App.css';
33

4+
const BACKEND_API_URL = process.env.BACKEND_API_URL || 'http://backend.localhost';
5+
46
const fetchContent = async (updateContent: (content: string) => void) => {
5-
const response = await fetch('http://localhost:3001/greetings/hello',{
7+
const response = await fetch(`${BACKEND_API_URL}/greetings/hello`,{
68
headers: {
79
'Accept': 'application/json',
810
'Content-Type': 'application/json',

frontend/webpack.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,9 @@ module.exports = {
2727
template: path.join(__dirname, "src/index.html"),
2828
}),
2929
],
30+
devServer: {
31+
host: '0.0.0.0',
32+
port: 3000,
33+
disableHostCheck: true,
34+
},
3035
};

0 commit comments

Comments
 (0)