From e1d79d2c79fba50dcbe0c7714d16333d273a8546 Mon Sep 17 00:00:00 2001 From: "theis.gaedigk" Date: Tue, 19 Aug 2025 23:55:13 +0200 Subject: [PATCH] fix: update port numbers and API endpoints for consistency across backend and frontend --- backend/Dockerfile | 2 +- backend/server.js | 2 +- docker-compose.yml | 32 +++++++++++++++++++------------ frontend/Dockerfile | 2 +- frontend/src/utils/fetchData.ts | 10 +++++----- frontend/src/utils/userHandler.ts | 4 ++-- frontend/vite.config.ts | 14 ++++++++------ 7 files changed, 38 insertions(+), 28 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 7167e5a..6507f20 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -7,6 +7,6 @@ RUN npm install COPY . . -EXPOSE 8002 +EXPOSE 8102 CMD ["npm", "start"] \ No newline at end of file diff --git a/backend/server.js b/backend/server.js index 4d28e0c..7646b15 100644 --- a/backend/server.js +++ b/backend/server.js @@ -5,7 +5,7 @@ import apiRouter from "./routes/api.js"; import apiRouterV2 from "./routes/apiV2.js"; env.config(); const app = express(); -const port = 8002; +const port = 8102; app.use(cors()); // Increase body size limits to support large CSV JSON payloads diff --git a/docker-compose.yml b/docker-compose.yml index 808f3ec..b9ff731 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,21 +1,25 @@ services: - # borrow_system-frontend: - # container_name: borrow_system-frontend - # build: ./frontend - # ports: - # - "8001:8001" - # environment: - # - CHOKIDAR_USEPOLLING=true - # volumes: - # - ./frontend:/app - # - /app/node_modules - # restart: unless-stopped + borrow_system-frontend: + container_name: borrow_system-frontend + build: ./frontend + ports: + - "8101:8101" + networks: + - proxynet + environment: + - CHOKIDAR_USEPOLLING=true + volumes: + - ./frontend:/app + - /app/node_modules + restart: unless-stopped borrow_system-backend: container_name: borrow_system-backend build: ./backend ports: - - "8002:8002" + - "8102:8102" + networks: + - proxynet environment: DB_HOST: mysql DB_USER: root @@ -41,3 +45,7 @@ services: volumes: mysql-data: + +networks: + proxynet: + external: true diff --git a/frontend/Dockerfile b/frontend/Dockerfile index b7dad9b..7f38f04 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -7,6 +7,6 @@ RUN npm install COPY . . -EXPOSE 8001 +EXPOSE 8101 CMD ["npm", "run", "dev"] \ No newline at end of file diff --git a/frontend/src/utils/fetchData.ts b/frontend/src/utils/fetchData.ts index db3584d..9f9a375 100644 --- a/frontend/src/utils/fetchData.ts +++ b/frontend/src/utils/fetchData.ts @@ -9,7 +9,7 @@ export const fetchAllData = async (token: string | undefined) => { if (!token) return; // First we fetch all items that are potentially available for borrowing try { - const response = await fetch("http://localhost:8002/api/items", { + const response = await fetch("https://backend.insta.the1s.de/api/items", { method: "GET", headers: { Authorization: `Bearer ${token}`, @@ -31,7 +31,7 @@ export const fetchAllData = async (token: string | undefined) => { // get all loans try { - const response = await fetch("http://localhost:8002/api/loans", { + const response = await fetch("https://backend.insta.the1s.de/api/loans", { method: "GET", headers: { Authorization: `Bearer ${token}`, @@ -53,7 +53,7 @@ export const fetchAllData = async (token: string | undefined) => { // get user loans try { - const response = await fetch("http://localhost:8002/api/userLoans", { + const response = await fetch("https://backend.insta.the1s.de/api/userLoans", { method: "GET", headers: { Authorization: `Bearer ${token}`, @@ -76,7 +76,7 @@ export const fetchAllData = async (token: string | undefined) => { export const loginUser = async (username: string, password: string) => { try { - const response = await fetch("http://localhost:8002/api/login", { + const response = await fetch("https://backend.insta.the1s.de/api/login", { method: "POST", headers: { "Content-Type": "application/json", @@ -112,7 +112,7 @@ export const getBorrowableItems = async () => { } try { - const response = await fetch("http://localhost:8002/api/borrowableItems", { + const response = await fetch("https://backend.insta.the1s.de/api/borrowableItems", { method: "POST", headers: { Authorization: `Bearer ${Cookies.get("token") || ""}`, diff --git a/frontend/src/utils/userHandler.ts b/frontend/src/utils/userHandler.ts index cf2a515..7e80267 100644 --- a/frontend/src/utils/userHandler.ts +++ b/frontend/src/utils/userHandler.ts @@ -4,7 +4,7 @@ import Cookies from "js-cookie"; export const handleDeleteLoan = async (loanID: number): Promise => { try { const response = await fetch( - `http://localhost:8002/api/deleteLoan/${loanID}`, + `https://backend.insta.the1s.de/api/deleteLoan/${loanID}`, { method: "DELETE", headers: { @@ -74,7 +74,7 @@ export const rmFromRemove = (itemID: number) => { export const createLoan = async (startDate: string, endDate: string) => { const items = removeArr; - const response = await fetch("http://localhost:8002/api/createLoan", { + const response = await fetch("https://backend.insta.the1s.de/api/createLoan", { method: "POST", headers: { "Content-Type": "application/json", diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index dd0234a..b7bd95c 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -1,15 +1,17 @@ import { defineConfig } from "vite"; -import react from "@vitejs/plugin-react"; -import svgr from "vite-plugin-svgr"; import tailwindcss from "@tailwindcss/vite"; export default defineConfig({ - plugins: [react(), svgr(), tailwindcss()], + plugins: [tailwindcss()], server: { host: "0.0.0.0", - port: 8001, - watch: { - usePolling: true, + allowedHosts: ["insta.the1s.de"], + port: 8101, + watch: { usePolling: true }, + hmr: { + host: "insta.the1s.de", + port: 8101, + protocol: "wss", }, }, });