proxy.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * @name 代理的配置
  3. * @see 在生产环境 代理是无法生效的,所以这里没有生产环境的配置
  4. * -------------------------------
  5. * The agent cannot take effect in the production environment
  6. * so there is no configuration of the production environment
  7. * For details, please see
  8. * https://pro.ant.design/docs/deploy
  9. *
  10. * @doc https://umijs.org/docs/guides/proxy
  11. */
  12. export default {
  13. // 如果需要自定义本地开发服务器 请取消注释按需调整
  14. dev: {
  15. // localhost:8000/api/** -> https://preview.pro.ant.design/api/**
  16. '/api/': {
  17. // 要代理的地址
  18. target: 'http://localhost:8080',
  19. // 配置了这个可以从 http 代理到 https
  20. // 依赖 origin 的功能可能需要这个,比如 cookie
  21. changeOrigin: true,
  22. pathRewrite: { '^/api': '' },
  23. },
  24. '/profile/avatar/': {
  25. target: 'http://localhost:8080',
  26. changeOrigin: true,
  27. }
  28. },
  29. /**
  30. * @name 详细的代理配置
  31. * @doc https://github.com/chimurai/http-proxy-middleware
  32. */
  33. test: {
  34. // localhost:8000/api/** -> https://preview.pro.ant.design/api/**
  35. '/api/': {
  36. target: 'https://proapi.azurewebsites.net',
  37. changeOrigin: true,
  38. pathRewrite: { '^': '' },
  39. },
  40. },
  41. pre: {
  42. '/api/': {
  43. target: 'your pre url',
  44. changeOrigin: true,
  45. pathRewrite: { '^': '' },
  46. },
  47. },
  48. };