diff --git a/.env.development b/.env.development index 3fd9174..2f12545 100755 --- a/.env.development +++ b/.env.development @@ -1,2 +1,2 @@ HOST=localhost -PORT=3000 +PORT=7777 diff --git a/config/mockCookie.txt b/config/mockCookie.txt new file mode 100644 index 0000000..edbb392 --- /dev/null +++ b/config/mockCookie.txt @@ -0,0 +1 @@ +UM_distinctid=1930b610f8be12-00856c472e2e16-1f525636-13c680-1930b610f8c32ce; JESONG_USER_ID=01000000027526106273070665702551; uid=703773; uname=%E6%89%8B%E6%9C%BA%E7%94%A8%E6%88%B7703773; role=3; user_name=%E6%89%8B%E6%9C%BA%E7%94%A8%E6%88%B7703773; avatar_file=https%3A%2F%2Fjulyedu-img-public.oss-cn-beijing.aliyuncs.com%2FPublic%2FImage%2Fhome%2Favatar_20191104.png; tfstk=g27KIBvcv5hLOeL0-yZiq2rTZkPgjaCeX95jrLvnVOBOaT3n-UYHVQ9OKDYoxWR-PdByKHYCETHRKOXJ4WJkFLBlNMVgorfFTU85e-40oSs3u-XKd397NVO2w5AIQv8FBU87nRmiPHzvztRM2RbC15dkZLM5FpM_6QdBP2tSRcM6QQTWPHgW5hOywXGBAT1_6QJ6FUTWrCq9UD9myi7Q3J5LUC0SPNdpXlfHCmph5BKph6_KP4GX9HpfOdy4UDh229KdSyH29G1AQBBzu28B2MsXRaeYJF1Vj9OOF-nJCiQFynbLHmJC8LWvRGesJUTeM_Kcj7ivIg1NWhQLmbRN-__emEaqdLjGMadRz8zOH66dcn_Ipg7CoZI85xvvZDNT60oyACkf3r2y9VajLCp0sBmr4hEw6KVtu0oyACR9n5Vj40-Tb; token=5ea65083947e06e9-2f9c41391bc9bc3d; access_token=5ea65083947e06e9-2f9c41391bc9bc3d; JESONG_AUTO_MON_TIMES=0; JESONG_VISITOR_ID=01000000027526385103079145651456; ssid=jlo1quiip5ct0h7crp783qd23f; ccode=0; plat=5 \ No newline at end of file diff --git a/config/proxy.js b/config/proxy.js index 37314b8..1c0f92d 100644 --- a/config/proxy.js +++ b/config/proxy.js @@ -1,44 +1,60 @@ +const fs = require("fs") +const path = require("path") +const cookiePath = path.resolve(__dirname, "./mockCookie.txt") +const cookie = fs.readFileSync(cookiePath, "utf8") + +function setCookieOnProxyReq(proxyReq, req, res) { + proxyReq.setHeader("Cookie", cookie) +} + module.exports = { "/homeApi": { target: "https://fast.julyedu.com", changeOrigin: true, secure: false, pathRewrite: { "^/homeApi": "" }, + onProxyReq: setCookieOnProxyReq, }, "/baseApi": { target: "https://api.julyedu.com", changeOrigin: true, secure: false, pathRewrite: { "^/baseApi": "" }, + onProxyReq: setCookieOnProxyReq, }, "/searchApi": { target: "https://search.julyedu.com", changeOrigin: true, secure: false, pathRewrite: { "^/searchApi": "" }, + onProxyReq: setCookieOnProxyReq, }, "/passportApi": { target: "https://passport.julyedu.com", changeOrigin: true, secure: false, pathRewrite: { "^/passportApi": "" }, + onProxyReq: setCookieOnProxyReq, }, "/record": { target: "https://record.julyedu.com", changeOrigin: true, secure: false, pathRewrite: { "^/record": "" }, + onProxyReq: setCookieOnProxyReq, }, "/mApi": { target: "https://m.julyedu.com", changeOrigin: true, secure: false, pathRewrite: { "^/mApi": "" }, + onProxyReq: setCookieOnProxyReq, }, "/ai-search": { target: "https://ai-search.julyedu.com", changeOrigin: true, secure: false, pathRewrite: { "^/ai-search": "" }, + onProxyReq: setCookieOnProxyReq, }, } diff --git a/public/api.js b/public/api.js index fbd18c6..4f82711 100755 --- a/public/api.js +++ b/public/api.js @@ -1,11 +1,11 @@ var API = { 'www': 'http://www-test.julyedu.com', - 'home': 'http://localhost:3000/homeApi', - 'search-api': 'http://localhost:3000/searchApi', - 'passport-api': 'http://localhost:3000/passportApi', - 'base-api': 'http://localhost:3000/baseApi', - 'record': 'http://localhost:3000/record', + 'home': 'http://localhost:7777/homeApi', + 'search-api': 'http://localhost:7777/searchApi', + 'passport-api': 'http://localhost:7777/passportApi', + 'base-api': 'http://localhost:7777/baseApi', + 'record': 'http://localhost:7777/record', 'process-api': 'ws:process-test.julyedu.com:9502', - 'm': 'http://localhost:3000/mApi', - 'ai-search': 'http://localhost:3000/ai-search', + 'm': 'http://localhost:7777/mApi', + 'ai-search': 'http://localhost:7777/ai-search', }