Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ services:
context: .
dockerfile: docker/node.Dockerfile
target: frontend-runtime
args:
VITE_API_BASE_URL: ${VITE_API_BASE_URL}
VITE_API_URL: ${VITE_API_URL}
VITE_APP_ENV: ${VITE_APP_ENV:-production}
container_name: vagas-frontend
env_file:
- ./frontend/.env
environment:
- VITE_API_PROXY_TARGET=http://backend:3001
ports:
- "5173:80"
depends_on:
Expand All @@ -74,13 +74,10 @@ services:
dockerfile: docker/node.Dockerfile
target: front-admin-runtime
args:
VITE_API_URL: https://api.candidate.app.br
VITE_APP_ENV: production
VITE_API_BASE_URL: ${VITE_API_BASE_URL}
VITE_API_URL: ${VITE_API_URL}
VITE_APP_ENV: ${VITE_APP_ENV:-production}
container_name: vagas-front-admin
env_file:
- ./front_admin/.env
environment:
- VITE_API_PROXY_TARGET=http://backend:3001
ports:
- "5174:80"
depends_on:
Expand Down
6 changes: 6 additions & 0 deletions docker/node.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ CMD ["npx","tsx","src/server.ts"]

FROM deps AS frontend

ARG VITE_API_BASE_URL
ARG VITE_API_URL

ENV VITE_API_BASE_URL=$VITE_API_BASE_URL
ENV VITE_API_URL=$VITE_API_URL

COPY frontend ./frontend

WORKDIR /app/frontend
Expand Down
8 changes: 7 additions & 1 deletion front_admin/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ COPY front_admin ./front_admin

WORKDIR /app/front_admin

ARG VITE_API_URL
ARG VITE_APP_ENV=production

ENV VITE_API_URL=$VITE_API_URL
ENV VITE_APP_ENV=$VITE_APP_ENV

RUN npm run build

# ---- Runtime ----
Expand All @@ -23,4 +29,4 @@ COPY front_admin/nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 80

CMD ["nginx", "-g", "daemon off;"]
CMD ["nginx", "-g", "daemon off;"]
2 changes: 2 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ RUN npm ci --workspace=frontend --include-workspace-root
COPY frontend/ ./frontend/
WORKDIR /app/frontend
ARG VITE_API_BASE_URL=http://localhost:3001
ARG VITE_API_URL=$VITE_API_BASE_URL
ENV VITE_API_BASE_URL=$VITE_API_BASE_URL
ENV VITE_API_URL=$VITE_API_URL
RUN npm run build

# ---- Etapa 2: serve ----
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/shared/lib/apiClient.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import axios from "axios";
import { parseApiError } from "./apiError";

const API_URL =
import.meta.env.VITE_API_BASE_URL ??
import.meta.env.VITE_API_URL ??
"http://localhost:3001";

export const api = axios.create({
baseURL: import.meta.env.VITE_API_URL ?? "http://localhost:3001",
baseURL: API_URL,
withCredentials: true,
headers: {
"Content-Type": "application/json",
Expand Down
Loading