vite.config

This commit is contained in:
Sedat ÖZTÜRK 2025-08-12 14:58:15 +03:00
parent b66c4a4aa7
commit 2674d0f838
4 changed files with 19 additions and 8 deletions

View file

@ -43,6 +43,8 @@ services:
profiles: ["app"]
ports:
- 3002:80 # ⚠️ UI uygulaması için dış port açıldı
volumes:
- /home/user/sozsoft.com:/etc/ssl/sozsoft.com:ro
networks:
- default

View file

@ -2,6 +2,8 @@ ARG ENV="dev"
FROM node:22-alpine
ARG ENV=$ENV
RUN apk add --no-cache ca-certificates && update-ca-certificates
ENV GENERATE_SOURCEMAP=false
ENV NODE_OPTIONS=--max-old-space-size=16384
WORKDIR /app

View file

@ -1,6 +1,7 @@
// scripts/tenant.ts
import axios from 'axios'
import https from 'https'
// import fs from 'fs'
export type TenantDto = { name: string }
export type PagedResultDto<T> = { totalCount: number; items: T[] }
@ -10,15 +11,15 @@ export async function fetchTenantNames(apiUrl: string): Promise<string[]> {
const url = `${apiUrl.replace(/\/$/, '')}/api/app/platform-tenant?skipCount=0&maxResultCount=1000`
const isLocalHttps = /^https:\/\/localhost(:\d+)?/i.test(apiUrl)
const response = await axios.get<PagedResultDto<TenantDto>>(url, {
headers: {
Accept: 'application/json',
'X-Requested-With': 'XMLHttpRequest',
},
// const ca = fs.readFileSync('../etc/ssl/sozsoft.com/fullchain1.pem')
// const agent = new https.Agent({ ca })
const { data } = await axios.get<PagedResultDto<TenantDto>>(url, {
headers: { Accept: 'application/json', 'X-Requested-With': 'XMLHttpRequest' },
httpsAgent: isLocalHttps ? new https.Agent({ rejectUnauthorized: false }) : undefined,
})
return (response.data.items ?? []).map((t: TenantDto) => t.name.trim().toLowerCase())
return (data.items ?? []).map((t) => t.name.trim().toLowerCase())
} catch (e) {
console.error('[vite] Tenant listesi alınamadı:', e)
return []

View file

@ -6,12 +6,18 @@ import { VitePWA } from 'vite-plugin-pwa'
import { fetchTenantNames } from './src/services/tenants'
export default defineConfig(async ({ mode }) => {
const baseDomains = ['sozsoft.com', 'dev.sozsoft.com']
const env = loadEnv(mode, process.cwd(), '')
const apiUrl = env.VITE_API_URL
const tenantNames = await fetchTenantNames(apiUrl)
const baseDomains = ['sozsoft.com', 'dev.sozsoft.com']
const tenantNames = (await fetchTenantNames(apiUrl)).map((n) => n.trim().toLowerCase())
const tenantHosts = tenantNames.flatMap((t) => baseDomains.map((d) => `${t}.${d}`))
const allowedHosts = Array.from(new Set(['localhost', ...baseDomains, ...tenantHosts]))
console.log('[vite] env:', env)
console.log('[vite] url:', apiUrl)
console.log('[vite] tenants:', tenantNames)
console.log('[vite] allowedHosts:', allowedHosts)
return {
plugins: [
react({