From b9eb903f93a8b3b6127711b0e183080936f180f1 Mon Sep 17 00:00:00 2001 From: kjuulh Date: Sun, 14 Nov 2021 19:37:04 +0100 Subject: [PATCH] Updated with server url --- src/client/Dockerfile | 3 +++ src/client/src/presentation/contexts/SocketContext.tsx | 5 ++++- src/docker-compose.prod.yml | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/client/Dockerfile b/src/client/Dockerfile index 60a1205..5ce7adc 100644 --- a/src/client/Dockerfile +++ b/src/client/Dockerfile @@ -9,6 +9,9 @@ RUN yarn install --frozen-lockfile # Rebuild the source code only when needed FROM node:14-alpine AS builder WORKDIR /app + +ARG NEXT_PUBLIC_SERVER_URL="http://localhost:5000" + COPY . . COPY --from=deps /app/node_modules ./node_modules RUN yarn build diff --git a/src/client/src/presentation/contexts/SocketContext.tsx b/src/client/src/presentation/contexts/SocketContext.tsx index b521afb..f1a7558 100644 --- a/src/client/src/presentation/contexts/SocketContext.tsx +++ b/src/client/src/presentation/contexts/SocketContext.tsx @@ -32,8 +32,11 @@ export const SocketProvider: FC = (props) => { const [inboxTodos, setInboxTodos] = useState([]); useEffect(() => { + const serverUrl = + process.env.NEXT_PUBLIC_SERVER_URL || "http://localhost:5000"; + const connection = new HubConnectionBuilder() - .withUrl("http://localhost:5000/hubs/todo") + .withUrl(`${serverUrl}/hubs/todo`) .withAutomaticReconnect() .configureLogging(LogLevel.Information) .build(); diff --git a/src/docker-compose.prod.yml b/src/docker-compose.prod.yml index 47df219..42f7f5c 100644 --- a/src/docker-compose.prod.yml +++ b/src/docker-compose.prod.yml @@ -31,5 +31,7 @@ services: restart: always build: context: client + args: + NEXT_PUBLIC_SERVER_URL: "https://api-todo.front.kjuulh.io" ports: - 12008:3000