分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > IT知识

插件http-proxy-middleware在vue-cli中的使用

发布时间:2023-09-06 01:24责任编辑:林大明关键词:http

作用:把后端的API(远程的API) 请求代理到本地服务器上,方便与后台数据调试,前后端分离

server.js 模拟远程API :localhost:8060/api/search  (测试前运行 node server.js)

  

在vue-cli中的使用:运行localhost: 8080

    1.在config文件夹下创建proxyConfig.js如下

        

    2. 在/config/index.js中 引入,并配置

      const  proxyConfig = require(‘./proxyConfig‘)

          

          

前端http请求远程API:在create钩子时调用 this.test() 请求到API结果:我是远程的数据源

      

 学习资料详细:

      1.https://github.com/chimurai/http-proxy-middleware

      2.https://vuejs-templates.github.io/webpack/proxy.htm

  

插件http-proxy-middleware在vue-cli中的使用

原文地址:http://www.cnblogs.com/xshaohua-com/p/7822399.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved