Browse Source

排除代理前缀

DESKTOP-QGP20P1\dev_2 6 months ago
parent
commit
79c1c538df
2 changed files with 15 additions and 23 deletions
  1. 9 20
      src/js/api.js
  2. 6 3
      webpack.config.js

+ 9 - 20
src/js/api.js

@@ -1,27 +1,16 @@
 
-// const api = {
-//   getGraph:'/api/ltkg/kg/getGraph',
-//   getNode:'/api/ltkg/kg/getNode',
-//   getSchema:'/api/ltkg/kg/getSchema',
-//   getTree:'/api/ltkg/kg/getTree',
-//   entity_predict:'api/ltkg/nlp/getNlp',
-//   getMrInfo:'/api/ltkg/presetInfo/getMrInfo',
-//   getAnswer:'/api/ltkg/qa/charBot',
-//   getTerm:'/api/ltkg/term/getTerm',
-//   check:'http://192.168.2.121:7010/test/testStandConvert',
-// };
-
 const api = {
-  getGraph:'/kg/getGraph',
-  getNode:'/kg/getNode',
-  getSchema:'/kg/getSchema',
-  getTree:'/kg/getTree',
-  entity_predict:'/nlp/getNlp',
-  getMrInfo:'/presetInfo/getMrInfo',
-  getAnswer:'/qa/charBot',
-  getTerm:'/term/getTerm',
+  getGraph:'/api/ltkg/kg/getGraph',
+  getNode:'/api/ltkg/kg/getNode',
+  getSchema:'/api/ltkg/kg/getSchema',
+  getTree:'/api/ltkg/kg/getTree',
+  entity_predict:'api/ltkg/nlp/getNlp',
+  getMrInfo:'/api/ltkg/presetInfo/getMrInfo',
+  getAnswer:'/api/ltkg/qa/charBot',
+  getTerm:'/api/ltkg/term/getTerm',
   check:'http://192.168.2.121:7010/test/testStandConvert',
 };
+
 $(".goto-homeStatic").on("click",function(){
   window.location.href = "http://192.168.2.121:5666"+$(this).attr("link");
 });

+ 6 - 3
webpack.config.js

@@ -6,8 +6,8 @@ const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
 const CopyWebpackPlugin = require('copy-webpack-plugin');
 const ExtractTextPlugin = require("extract-text-webpack-plugin");
 const webpack = require('webpack');
+// const proxyHost = "http://173.18.12.192:8775";
 const proxyHost = "http://173.18.12.192:8775";
-// const proxyHost = "http://173.18.12.191:1388";
 // const proxyHost = "http://192.168.3.113:5050";
 // const proxyHost = "http://173.18.12.192:5050";
 module.exports = {
@@ -212,10 +212,13 @@ module.exports = {
   devServer: {
     contentBase: "./dist", //静态文件根目录
     proxy: {
-      '/': proxyHost
+        '/api/ltkg': {
+        target: proxyHost,    // 后端服务器地址
+        changeOrigin: true,    // 如果目标服务器不是本地服务器,需要设置为 true
+        pathRewrite: { '^/api/ltkg': '' }   // 将 /api 前缀重写为空字符串
+      }
     },
     hot: true,
     openPage: 'knowledgeGraph.html'
-
   }
 }