feat: enhance Vite configuration with dynamic allowed hosts and update Nginx server_name

This commit is contained in:
Your Name
2026-03-16 23:44:11 +02:00
parent f933ffa8a0
commit 1eb9faf6ca
3 changed files with 22 additions and 1 deletions

Binary file not shown.

View File

@@ -3,6 +3,22 @@ import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react'; import react from '@vitejs/plugin-react';
import path from 'path'; import path from 'path';
function getAllowedHosts() {
const defaultHosts = ['dociva.io', 'www.dociva.io', 'localhost', '127.0.0.1'];
const siteDomain = process.env.VITE_SITE_DOMAIN;
if (!siteDomain) {
return defaultHosts;
}
try {
const hostname = new URL(siteDomain).hostname;
return Array.from(new Set([...defaultHosts, hostname]));
} catch {
return defaultHosts;
}
}
export default defineConfig({ export default defineConfig({
plugins: [react()], plugins: [react()],
test: { test: {
@@ -17,6 +33,7 @@ export default defineConfig({
server: { server: {
port: 5173, port: 5173,
host: true, host: true,
allowedHosts: getAllowedHosts(),
proxy: { proxy: {
'/api': { '/api': {
target: 'http://backend:5000', target: 'http://backend:5000',
@@ -24,6 +41,10 @@ export default defineConfig({
}, },
}, },
}, },
preview: {
host: true,
allowedHosts: getAllowedHosts(),
},
build: { build: {
outDir: 'dist', outDir: 'dist',
sourcemap: false, sourcemap: false,

View File

@@ -8,7 +8,7 @@ upstream frontend {
server { server {
listen 80; listen 80;
server_name localhost; server_name localhost 127.0.0.1 178.104.57.123 dociva.io www.dociva.io;
client_max_body_size 100M; client_max_body_size 100M;
# Security headers # Security headers