vite.config.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. changeOrigin: true,
  14. secure: false,
  15. configure: (proxy) => {
  16. proxy.on('error', (err, req) => {
  17. // 把 AggregateError.errors 全部展开, 看每个 IP 的真实失败原因
  18. const inner = (err as any)?.errors
  19. // eslint-disable-next-line no-console
  20. console.error('[proxy error]', req?.method, req?.url,
  21. '\n name:', err?.name,
  22. '\n code:', (err as any)?.code,
  23. '\n msg:', err?.message,
  24. '\n inner:', Array.isArray(inner)
  25. ? inner.map((e: any) => `${e?.code}@${e?.address}:${e?.port} ${e?.message}`).join(' | ')
  26. : 'none')
  27. })
  28. proxy.on('proxyReq', (_pReq, req) => {
  29. // eslint-disable-next-line no-console
  30. console.log('[proxy req]', req?.method, req?.url)
  31. })
  32. },
  33. },
  34. },
  35. },
  36. })