diff --git a/docker-compose.yaml b/docker-compose.yaml index f0c3ed0..51c3931 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -26,6 +26,8 @@ services: volumes: - ./frontend:/app working_dir: /app + ports: + - "3000:3000" command: sh -c "npm install; npm start" postgres: @@ -51,5 +53,6 @@ services: - frontend volumes: - ./nginx.conf:/etc/nginx/nginx.conf + - ./backend/right_tree/staticfiles:/etc/nginx/html/staticfiles ports: - "9000:80" diff --git a/frontend/src/repository/Repository.js b/frontend/src/repository/Repository.js index 9a697ab..9848651 100644 --- a/frontend/src/repository/Repository.js +++ b/frontend/src/repository/Repository.js @@ -2,7 +2,7 @@ import axios from "axios" // Create the axios object const repo = axios.create({ - baseURL: "/api", + baseURL: window.location.hostname == 'localhost' ? "http://localhost:9000/api" : "/api", }); repo.defaults.headers.post["access-control-allow-origin"] = "*"; diff --git a/nginx.conf b/nginx.conf index 8db9391..d80c8bc 100644 --- a/nginx.conf +++ b/nginx.conf @@ -8,6 +8,10 @@ http { proxy_pass http://frontend:3000; } + location /staticfiles { + root /etc/nginx/html/; + } + location ~* ^/(api|admin) { proxy_pass http://backend:8000; }