12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- // 代理环境映射表
- const ProxyTargets = {
- prod: 'https://www.jianyu360.cn',
- webdev: 'https://webdev-webtest.jydev.jianyu360.com',
- web3: 'https://jybx3-webtest.jydev.jianyu360.com',
- web2: 'https://jybx2-webtest.jydev.jianyu360.com',
- web: 'https://jybx-webtest.jydev.jianyu360.com',
- app5: 'https://app5-jytest.jydev.jianyu360.com'
- }
- // 需要代理的请求前缀
- const ProxyPrefixes = [
- // 请求代理
- '/bigmember',
- '/entbase',
- '/entnicheNew',
- '/front',
- '/phone',
- '/userCenter',
- '/OnlineCourses',
- '/publicapply',
- '/privatedata',
- '/subscribepay',
- '/salesLeads',
- '/jyapi',
- '/jypay',
- '/jyCoupon',
- '/jymessageCenter',
- '/jyMerge',
- '/jydocs',
- '/leadGeneration',
- '/member',
- '/commercial',
- '/jyNewApi',
- // 静态资源代理
- '/commonFunctions',
- '/common-module',
- '/public-pc',
- '/pccss',
- '/js',
- '/css',
- '/antiRes',
- '/images/wx/'
- ]
- export function useServerProxy(domain, defaultProxy = {}) {
- const ProxyTarget = ProxyTargets[domain] || domain
- const DevProxy = Object.assign({}, defaultProxy, {
- '^/dev-api': {
- target: ProxyTarget,
- changeOrigin: true,
- rewrite: (path) => path.replace(/^\/dev-api/, '/')
- },
- '^/succbi': {
- target: ProxyTarget,
- changeOrigin: true
- },
- // 接口解密iframe
- '^/page_decrypt': {
- target: ProxyTarget,
- changeOrigin: true
- }
- })
- const ProxyRules = ProxyPrefixes.reduce((a, b) => {
- a[b] = ProxyTarget
- return a
- }, DevProxy)
- return ProxyRules
- }
|