We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
习惯了前后端分离,习惯了webpack之类的工作流,一遇到后端渲染模板的项目在本机无后端服务调试的时候,大脑一片空白,接口调试不可能说写好放到后端那边去测试,虽然公司有测试服务器,但一直没被重视,基本上就是各自为战,有点可怕。
为了应付调试接口,可以使用下面代码进行启动代理服务进行测试。
本地安装node,然后安装以下2个包
npm install --save-dev express http-proxy-middleware
var express = require('express'); var proxyMiddleWare = require("http-proxy-middleware"); var proxyPath = "http://172.16.0.180:8188";//目标后端服务地址(公司同事电脑地址) var proxyOption ={target:proxyPath,changeOrigoin:true}; var app = express(); app.use(express.static("./static")); app.use("/goddessActivity/insertInfo",proxyMiddleWare(proxyOption))//这里要注意"/discern" 是匹配的路由,它会将匹配的路由进行转发,没匹配到的就不会转发。('/discern'完全可以写成'/'就是说所有路由都可以访问) app.use("/goddessActivity/getPolicy",proxyMiddleWare(proxyOption))//这里要注意"/discern" 是匹配的路由,它会将匹配的路由进行转发,没匹配到的就不会转发。('/discern'完全可以写成'/'就是说所有路由都可以访问) app.listen(8000);
在JS中请求地址,请使用http://127.0.0.1:8000/+上面配置的地址
The text was updated successfully, but these errors were encountered:
No branches or pull requests
习惯了前后端分离,习惯了webpack之类的工作流,一遇到后端渲染模板的项目在本机无后端服务调试的时候,大脑一片空白,接口调试不可能说写好放到后端那边去测试,虽然公司有测试服务器,但一直没被重视,基本上就是各自为战,有点可怕。
为了应付调试接口,可以使用下面代码进行启动代理服务进行测试。
本地安装node,然后安装以下2个包
在JS中请求地址,请使用http://127.0.0.1:8000/+上面配置的地址
The text was updated successfully, but these errors were encountered: