在vite.config.ts
中添加
**import { defineConfig } from 'vite'
import reactRefresh from '@vitejs/plugin-react-refresh'
// https://vitejs.dev/config/
export default defineConfig({
server: {
proxy: {
'/api': {
target: 'http://ali.testops.top:9200',
// target: 'http://localhost:9200',
changeOrigin: true,
rewrite: (path: string) => {
// console.log('http://ali.testops.top:9199' + path.replace(/^\/api/, ''));
return path.replace(/^\/api/, '')
}
}
}
},
plugins: [reactRefresh()],
})**