Skip to content

Commit

Permalink
DBZ-8406 Get backend ulr from env (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfvitale authored Nov 15, 2024
1 parent 965ede2 commit 8e6faa2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
FROM registry.access.redhat.com/ubi9/nodejs-20 AS builder
RUN npm install -g yarn

ENV VITE_BACKEND_BASE_URL=http://localhost:8080
ARG BACKEND_URL=http://localhost:8080
ENV VITE_BACKEND_BASE_URL=${BACKEND_URL}

WORKDIR /app
COPY package.json yarn.lock ./
Expand Down
9 changes: 7 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,24 @@ import type { InlineConfig } from "vitest";
import type { UserConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import tsconfigPaths from 'vite-tsconfig-paths';
import { loadEnv } from 'vite';

const env = loadEnv('all', process.cwd(), 'VITE_');
const API_URL = `${env.VITE_BACKEND_API_URL ?? 'http://localhost:8080'}`;
const PORT = `${env.VITE_PORT ?? '3000'}`;

type ViteConfig = UserConfig & { test: InlineConfig };
const config: ViteConfig = {
plugins: [react(), tsconfigPaths()],
server: {
proxy: {
"/api": {
target: "http://localhost:8080",
target: API_URL,
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, "/api"), // Keep '/api' prefix
},
},
port: 3000,
port: PORT,
},
test: {
// 👋 add the line below to add jsdom to vite
Expand Down

0 comments on commit 8e6faa2

Please sign in to comment.