Skip to content

add support for VITE_API_URL environment variable with sensible defaults #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ RUN npm install
# Copy the rest of the frontend source code
COPY frontend/ ./

# Add the build argument for the backend API URL to be used by the frontend
ARG VITE_API_URL

# Set the environment variable so Vite can access the backend API URL during build
ENV VITE_API_URL=${VITE_API_URL}

# Build the frontend
RUN npm run build

Expand Down
4 changes: 3 additions & 1 deletion backend/.env.example
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# GEMINI_API_KEY=
# GEMINI_API_KEY=
# LANGSMITH_API_KEY=
# VITE_API_URL=http://localhost:8123
5 changes: 5 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ services:
retries: 5
interval: 5s
langgraph-api:
build:
context: .
dockerfile: Dockerfile
args:
VITE_API_URL: ${VITE_API_URL}
image: gemini-fullstack-langgraph
container_name: langgraph-api
ports:
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export default function App() {
max_research_loops: number;
reasoning_model: string;
}>({
apiUrl: import.meta.env.DEV
apiUrl: import.meta.env.VITE_API_URL || (import.meta.env.DEV
? "http://localhost:2024"
: "http://localhost:8123",
: "http://localhost:8123"),
assistantId: "agent",
messagesKey: "messages",
onUpdateEvent: (event: any) => {
Expand Down