fix: update database connection URL and configure frontend build context
All checks were successful
Release and Build Docker Images / release-and-build (push) Successful in 1m30s

This commit is contained in:
almazlar
2026-02-22 12:18:37 +03:00
parent 223a960142
commit 000d1db6b1
3 changed files with 16 additions and 4 deletions

View File

@@ -146,3 +146,4 @@ jobs:
labels: ${{ steps.meta-frontend.outputs.labels }}
build-args: |
VITE_APP_VERSION=${{ steps.generate.outputs.new_tag }}
VITE_BASE_URL=https://todo.almazlar.com/api/todos

View File

@@ -24,7 +24,7 @@ services:
ports:
- "8082:8080"
environment:
- SPRING_DATASOURCE_URL=jdbc:postgresql://db:5433/tododb
- SPRING_DATASOURCE_URL=jdbc:postgresql://db:5432/tododb
- SPRING_DATASOURCE_USERNAME=postgres
- SPRING_DATASOURCE_PASSWORD=postgres
depends_on:
@@ -32,12 +32,16 @@ services:
condition: service_healthy
frontend:
build: ./frontend
build:
context: ./frontend
args:
VITE_BASE_URL: "http://localhost:8082/api/todos"
container_name: todo-frontend
ports:
- "5173:80"
depends_on:
- backend
volumes:
postgres_data:

View File

@@ -1,4 +1,12 @@
const BASE_URL = 'https://todo.almazlar.com/api/todos';
// src/services/api.js
// Vite automatically injects the variable defined in .env.* based on the current mode.
// `import.meta.env.VITE_BASE_URL` is the single source of truth for the API root.
const BASE_URL = import.meta.env.VITE_BASE_URL;
// -----------------------------------------------------------------------------
// API helpers
// -----------------------------------------------------------------------------
export const getTodos = async () => {
const response = await fetch(BASE_URL);
@@ -35,7 +43,6 @@ export const deleteTodo = async (id) => {
};
export const getVersion = async () => {
// Use the origin to ensure it accesses the /api/version correctly regardless of environment
const VERSION_URL = BASE_URL.replace('/todos', '/version');
const response = await fetch(VERSION_URL);
if (!response.ok) throw new Error('Failed to fetch version');