ci/woodpecker/push/woodpecker Pipeline was successful
Co-authored-by: HiFox Agent <agents-noreply@hifox.com>
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import { defineConfig, loadEnv } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import tailwindcss from '@tailwindcss/vite';
|
|
import { energyDevMockApi } from './src/modules/energy/hydrogen-bi-v2/dev-mock-api';
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd(), '');
|
|
|
|
return {
|
|
plugins: [
|
|
react(),
|
|
tailwindcss(),
|
|
...(env.DEV_MOCK_API === '1' ? [energyDevMockApi()] : []),
|
|
],
|
|
server: {
|
|
allowedHosts: ['biz.u2145933.nyat.app'],
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://localhost:3001',
|
|
changeOrigin: true,
|
|
configure(proxy) {
|
|
// A failed upstream BI aggregation must become an HTTP error for
|
|
// the UI fallback, never terminate the 8115 preview process.
|
|
proxy.on('error', (_error, _request, response) => {
|
|
if (response && 'writeHead' in response && !response.headersSent) {
|
|
response.writeHead(502, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
response.end('Upstream API temporarily unavailable');
|
|
}
|
|
});
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
});
|