vite.config
This commit is contained in:
parent
b66c4a4aa7
commit
8db7066617
2 changed files with 7 additions and 2 deletions
|
|
@ -9,6 +9,7 @@ export async function fetchTenantNames(apiUrl: string): Promise<string[]> {
|
|||
try {
|
||||
const url = `${apiUrl.replace(/\/$/, '')}/api/app/platform-tenant?skipCount=0&maxResultCount=1000`
|
||||
const isLocalHttps = /^https:\/\/localhost(:\d+)?/i.test(apiUrl)
|
||||
console.log('[vite] tenants url:', url)
|
||||
|
||||
const response = await axios.get<PagedResultDto<TenantDto>>(url, {
|
||||
headers: {
|
||||
|
|
|
|||
|
|
@ -6,12 +6,16 @@ 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] tenants:', tenantNames)
|
||||
console.log('[vite] allowedHosts:', allowedHosts)
|
||||
|
||||
return {
|
||||
plugins: [
|
||||
react({
|
||||
|
|
|
|||
Loading…
Reference in a new issue