vite.config.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { defineConfig } from 'vite'
  2. import react from '@vitejs/plugin-react'
  3. // 后端运行在 8080,前端开发期通过代理避免跨域
  4. export default defineConfig({
  5. plugins: [react()],
  6. base: '/content-similarity-recall/', // CDN 部署路径
  7. server: {
  8. port: 5173,
  9. host: true,
  10. proxy: {
  11. '/videoVector': {
  12. target: 'https://api-internal.piaoquantv.com',
  13. // target: 'http://localhost:8080',
  14. changeOrigin: true,
  15. secure: false,
  16. configure: (proxy) => {
  17. proxy.on('error', (err, req) => {
  18. // 把 AggregateError.errors 全部展开, 看每个 IP 的真实失败原因
  19. const inner = (err as any)?.errors
  20. // eslint-disable-next-line no-console
  21. console.error('[proxy error]', req?.method, req?.url,
  22. '\n name:', err?.name,
  23. '\n code:', (err as any)?.code,
  24. '\n msg:', err?.message,
  25. '\n inner:', Array.isArray(inner)
  26. ? inner.map((e: any) => `${e?.code}@${e?.address}:${e?.port} ${e?.message}`).join(' | ')
  27. : 'none')
  28. })
  29. proxy.on('proxyReq', (_pReq, req) => {
  30. // eslint-disable-next-line no-console
  31. console.log('[proxy req]', req?.method, req?.url)
  32. })
  33. },
  34. },
  35. },
  36. },
  37. })