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


export default defineConfig({
  plugins: [react(), tailwindcss()],

  server: {
    proxy: {
      '/sites': {
        target: 'http://modest-turquoise-bear.168-235-125-96.cpanel.site',
        changeOrigin: true,
        headers: {
          'X-Requested-With': 'XMLHttpRequest',
        },
      },
      '/jsonapi': {
        target: 'http://modest-turquoise-bear.168-235-125-96.cpanel.site',
        changeOrigin: true,
        headers: {
          'X-Requested-With': 'XMLHttpRequest',
        },
        configure: (proxy) => {
          proxy.on('proxyReq', (proxyReq) => {
            // Decode the URL so commas are not double-encoded
            proxyReq.path = decodeURIComponent(proxyReq.path);
          });
        },
      },
      '/session': {
        target: 'https://modest-turquoise-bear.168-235-125-96.cpanel.site',
        changeOrigin: true,
        secure: false,
      }
    }
  },
})