vite.config.js 2.0 KB

123456789101112131415161718192021222324252627282930313233
  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: function (proxy) {
  17. proxy.on('error', function (err, req) {
  18. // 把 AggregateError.errors 全部展开, 看每个 IP 的真实失败原因
  19. var inner = err === null || err === void 0 ? void 0 : err.errors;
  20. // eslint-disable-next-line no-console
  21. console.error('[proxy error]', req === null || req === void 0 ? void 0 : req.method, req === null || req === void 0 ? void 0 : req.url, '\n name:', err === null || err === void 0 ? void 0 : err.name, '\n code:', err === null || err === void 0 ? void 0 : err.code, '\n msg:', err === null || err === void 0 ? void 0 : err.message, '\n inner:', Array.isArray(inner)
  22. ? inner.map(function (e) { return "".concat(e === null || e === void 0 ? void 0 : e.code, "@").concat(e === null || e === void 0 ? void 0 : e.address, ":").concat(e === null || e === void 0 ? void 0 : e.port, " ").concat(e === null || e === void 0 ? void 0 : e.message); }).join(' | ')
  23. : 'none');
  24. });
  25. proxy.on('proxyReq', function (_pReq, req) {
  26. // eslint-disable-next-line no-console
  27. console.log('[proxy req]', req === null || req === void 0 ? void 0 : req.method, req === null || req === void 0 ? void 0 : req.url);
  28. });
  29. },
  30. },
  31. },
  32. },
  33. });