import path from 'path'
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

const proxyTargetAPI = process.env.VITE_PROXY_TARGET_API || 'http://localhost:8080';
const proxyTargetMedia = process.env.VITE_PROXY_TARGET_MEDIA || proxyTargetAPI;

// https://vite.dev/config/
export default defineConfig({
    plugins: [react()],
    resolve: {
        alias: {
            "@": path.resolve(__dirname, "./src"),
        },
    },
    server: {
        proxy: {
            '/api': {
                target: proxyTargetAPI,
                changeOrigin: true,
                secure: false,
            },
            '/media': {
                target: proxyTargetMedia,
                changeOrigin: true,
                secure: false,
            },
        },
    },
});
