import { fileURLToPath, URL } from 'node:url' import tailwindcss from '@tailwindcss/vite' import react from '@vitejs/plugin-react' import { defineConfig } from 'vite' import pkg from './package.json' with { type: 'json' } // https://vite.dev/config/ export default defineConfig({ plugins: [react(), tailwindcss()], resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)), }, }, define: { __APP_VERSION__: JSON.stringify(pkg.version), }, server: { port: process.env.PORT ? Number(process.env.PORT) : 8094, // Same-origin dev proxy for the REST layer only -- avoids CORS entirely (the browser only ever // sees http://localhost:8094) so a resolved tenant's *relative* endpoints ("/v1/im", "/v0/file") // work unmodified in local dev, same idea as the old app's hand-rolled dev-proxy-server.js, just // using Vite's built-in proxy instead of a bespoke Node server. The Tinode WS connection itself // does NOT need this: WebSocket isn't subject to the fetch() same-origin policy, so it connects // straight to the tenant's real host regardless (confirmed working this way throughout the old // app's development too). proxy: { '/v1/im': { target: 'https://api.118im.com', changeOrigin: true, secure: true }, '/v0/file': { target: 'https://api.118im.com', changeOrigin: true, secure: true }, }, }, })