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
10 changes: 8 additions & 2 deletions synkronus-portal/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html

# Copy custom nginx configuration for SPA routing
# Backend API: http://demo.synkronus.cloud
RUN echo 'server { \
listen 0.0.0.0:80; \
listen [::]:80; \
Expand All @@ -32,17 +33,22 @@ RUN echo 'server { \
location / { \
try_files $uri $uri/ /index.html; \
} \
# Proxy API requests to backend \
# Proxy API requests to backend (demo.synkronus.cloud) \
location /api { \
rewrite ^/api(.*)$ $1 break; \
proxy_pass http://demo.synkronus.cloud; \
proxy_http_version 1.1; \
proxy_set_header Upgrade $http_upgrade; \
proxy_set_header Connection "upgrade"; \
proxy_set_header Host $host; \
proxy_set_header Host demo.synkronus.cloud; \
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; \
proxy_set_header X-Forwarded-Host $host; \
proxy_connect_timeout 60s; \
proxy_send_timeout 60s; \
proxy_read_timeout 60s; \
proxy_buffering off; \
client_max_body_size 100M; \
} \
}' > /etc/nginx/conf.d/default.conf
Expand Down
8 changes: 4 additions & 4 deletions synkronus-portal/src/pages/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export function Dashboard() {
try {
const [info, healthResponse] = await Promise.all([
api.get<SystemInfo>('/version').catch(() => null),
fetch(`${import.meta.env.DEV ? '/api' : 'http://localhost:8080'}/health`).catch(() => null)
fetch(`${import.meta.env.VITE_API_URL || '/api'}/health`).catch(() => null)
])
if (info) setSystemInfo(info)

Expand Down Expand Up @@ -355,7 +355,7 @@ export function Dashboard() {
xhr.addEventListener('error', () => reject(new Error('Network error: Upload failed')))
xhr.addEventListener('abort', () => reject(new Error('Upload was cancelled')))

const apiBaseUrl = import.meta.env.VITE_API_URL || (import.meta.env.DEV ? '/api' : 'http://localhost:8080')
const apiBaseUrl = import.meta.env.VITE_API_URL || '/api'
const uploadUrl = `${apiBaseUrl}/app-bundle/push`
xhr.open('POST', uploadUrl)
if (token) {
Expand Down Expand Up @@ -400,7 +400,7 @@ export function Dashboard() {
setError(null)
setSuccess(null)
try {
const apiBaseUrl = import.meta.env.VITE_API_URL || (import.meta.env.DEV ? '/api' : 'http://localhost:8080')
const apiBaseUrl = import.meta.env.VITE_API_URL || '/api'
const token = localStorage.getItem('token')

const response = await fetch(`${apiBaseUrl}/dataexport/parquet`, {
Expand Down Expand Up @@ -1334,7 +1334,7 @@ export function Dashboard() {
<div className="info-content">
<h3>API Endpoint</h3>
<p style={{ fontSize: '13px', fontFamily: 'monospace', wordBreak: 'break-all' }}>
{import.meta.env.VITE_API_URL || (import.meta.env.DEV ? '/api' : 'http://localhost:8080')}
{import.meta.env.VITE_API_URL || '/api'}
</p>
</div>
</div>
Expand Down
6 changes: 4 additions & 2 deletions synkronus-portal/src/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ const getApiBaseUrl = () => {
if (import.meta.env.VITE_API_URL) {
return import.meta.env.VITE_API_URL
}
// Use proxy in development, direct URL in production
return import.meta.env.DEV ? '/api' : 'http://localhost:8080'
// Use /api proxy in both development and production
// In development: Vite dev server proxies /api to backend
// In production: Nginx proxies /api to http://demo.synkronus.cloud
return '/api'
}

const API_BASE_URL = getApiBaseUrl()
Expand Down