Fix initial user creating

This commit is contained in:
2026-04-29 00:55:00 +03:00
parent 3565390a49
commit 66c84ecdeb
16 changed files with 267 additions and 35 deletions

View File

@@ -1,2 +1,2 @@
VITE_API_URL=http://localhost:3000/api/v1
VITE_API_URL=/api/v1
VITE_API_KEY=dev_key_12345678

View File

@@ -3,7 +3,7 @@ FROM node:18-alpine as build
WORKDIR /app
ARG VITE_API_URL=http://localhost:3000/api/v1
ARG VITE_API_URL=/api/v1
ENV VITE_API_URL=$VITE_API_URL
COPY package*.json ./

View File

@@ -10,6 +10,28 @@ server {
gzip_min_length 1000;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
# Same-origin API proxy for deployed admin panel
location /api/ {
proxy_pass http://backend:3000;
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 /ws/ {
proxy_pass http://backend:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
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;
proxy_read_timeout 3600s;
}
# SPA routing
location / {
try_files $uri $uri/ /index.html;

View File

@@ -117,7 +117,7 @@ export default function LoginPage() {
Мастер-аккаунт по умолчанию:
</p>
<p className="text-xs text-gray-500 mt-1">
<code className="bg-gray-100 px-2 py-1 rounded">admin / admin123</code>
<code className="bg-gray-100 px-2 py-1 rounded">admin / ADMIN_PASSWORD</code>
</p>
</div>
</div>
@@ -129,4 +129,4 @@ export default function LoginPage() {
</div>
</div>
);
}
}

View File

@@ -1,4 +1,4 @@
const DEFAULT_API_BASE_URL = 'http://localhost:3000/api/v1';
const DEFAULT_API_BASE_URL = '/api/v1';
function normalizePath(pathname) {
const trimmedPath = (pathname || '').replace(/\/+$/, '');
@@ -40,6 +40,6 @@ export function getApiOrigin(rawValue = import.meta.env.VITE_API_URL || DEFAULT_
const url = new URL(getApiBaseUrl(rawValue));
return `${url.protocol}//${url.host}`;
} catch (error) {
return 'http://localhost:3000';
return typeof window !== 'undefined' ? window.location.origin : 'http://localhost:3000';
}
}

View File

@@ -5,7 +5,17 @@ export default defineConfig({
plugins: [react()],
server: {
host: true,
port: 3001
port: 3001,
proxy: {
'/api': {
target: 'http://localhost:3000',
changeOrigin: true
},
'/ws': {
target: 'ws://localhost:3000',
ws: true
}
}
},
build: {
outDir: 'dist',