From 7eddfb28b085979c359af56c18dfa9d22f26aacb Mon Sep 17 00:00:00 2001 From: Verum Date: Thu, 19 Mar 2026 16:36:41 +0700 Subject: [PATCH] 5324 --- .env.example | 2 +- docker-compose.yml | 2 +- frontend/nginx.conf | 9 +++++++++ frontend/src/api/client.js | 2 +- infra/postgres/init.sql | 3 ++- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index 65f0f16..4e18c1e 100644 --- a/.env.example +++ b/.env.example @@ -4,6 +4,6 @@ DATABASE_URL=postgresql://postgres:postgres@localhost:5432/app_admin SESSION_SECRET=change-me SESSION_NAME=pgcc.sid ALLOWED_ORIGIN=http://localhost:5173 -POSTGRES_CONTAINER_NAME=pg-control-postgres +POSTGRES_CONTA INER_NAME=pg-control-postgres COOKIE_SECURE=false diff --git a/docker-compose.yml b/docker-compose.yml index c9f61b2..eba8cd3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -49,7 +49,7 @@ services: context: ./frontend dockerfile: Dockerfile args: - VITE_API_BASE_URL: http://localhost:4000/api + VITE_API_BASE_URL: /api container_name: pg-control-frontend restart: unless-stopped depends_on: diff --git a/frontend/nginx.conf b/frontend/nginx.conf index 8897f2f..c497b23 100644 --- a/frontend/nginx.conf +++ b/frontend/nginx.conf @@ -5,6 +5,15 @@ server { root /usr/share/nginx/html; index index.html; + location /api/ { + proxy_pass http://backend:4000/api/; + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } + location / { try_files $uri $uri/ /index.html; } diff --git a/frontend/src/api/client.js b/frontend/src/api/client.js index 3d0ab7f..50209be 100644 --- a/frontend/src/api/client.js +++ b/frontend/src/api/client.js @@ -1,4 +1,4 @@ -const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || "http://localhost:4000/api"; +const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || "/api"; async function request(path, options = {}) { const response = await fetch(`${API_BASE_URL}${path}`, { diff --git a/infra/postgres/init.sql b/infra/postgres/init.sql index 0c88b77..792ec49 100644 --- a/infra/postgres/init.sql +++ b/infra/postgres/init.sql @@ -43,10 +43,11 @@ create table if not exists table_group_tables ( ); create table if not exists role_permissions ( + id uuid primary key default gen_random_uuid(), role_id uuid not null references roles(id) on delete cascade, permission_id uuid not null references permissions(id) on delete cascade, table_group_id uuid references table_groups(id) on delete cascade, - primary key(role_id, permission_id, table_group_id) + unique nulls not distinct (role_id, permission_id, table_group_id) ); create table if not exists audit_logs (