proxy.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. const env = require('../parseEnv');
  2. let apiRootPath = env._SETTING_API_BASE_PATH.replace(/"/g, '') || '';
  3. const proxySetting = {
  4. [`/${apiRootPath}/labeling`]: {
  5. target: env._SETTING_SERVER_PROXY_PROJECT.replace(/"/g, ''),
  6. changeOrigin: true,
  7. secure: false,
  8. ...(env._SETTING_SERVER_PROXY !== env._SETTING_SERVER_PROXY_PROJECT && {
  9. pathRewrite: {
  10. [`^/${apiRootPath}/labeling/`]: '/',
  11. },
  12. }),
  13. },
  14. [`/${apiRootPath}/bc`]: {
  15. target: env._SETTING_SERVER_PROXY_BC.replace(/"/g, ''),
  16. changeOrigin: true,
  17. ...(env._SETTING_SERVER_PROXY !== env._SETTING_SERVER_PROXY_BC && {
  18. pathRewrite: {
  19. [`^/${apiRootPath}/bc/`]: '/',
  20. },
  21. }),
  22. },
  23. [`/${apiRootPath}/uc`]: {
  24. target: env._SETTING_SERVER_PROXY_UC.replace(/"/g, ''),
  25. changeOrigin: true,
  26. ...(env._SETTING_SERVER_PROXY !== env._SETTING_SERVER_PROXY_UC && {
  27. pathRewrite: {
  28. [`^/${apiRootPath}/uc/`]: '/',
  29. },
  30. }),
  31. },
  32. [`/${apiRootPath}/traintask`]: {
  33. target: env._SETTING_SERVER_PROXY_TRAIN_TASK.replace(/"/g, ''),
  34. changeOrigin: true,
  35. pathRewrite: {
  36. [`^/${apiRootPath}/traintask/`]: '/',
  37. },
  38. },
  39. };
  40. module.exports = {
  41. proxySetting,
  42. };