zoukankan      html  css  js  c++  java
  • vue-cli proxytable 跨域代理配置

    1.配置位置:config文件夹下index.js

    2.proxy文件

    如果接口中不含/api_100这个接口时的配置文件,(把target为http://192.168.1.10/web_test/index.php/api2_100的地址映射为/api_100,pathRewrite将/api_100替换为空,)
    附一个醍醐灌顶的链接 https://segmentfault.com/q/1010000012607105/a-1020000012607329
    module.exports = {
    proxy: {
    '/api_100': {
    target: 'http://192.168.1.10/web_test/index.php/api2_100',
    secure: false,
    changeOrigin: true, // 是否跨域
    pathRewrite: {
    '^/api_100': '' // 需要rewrite的地址
    }
    }
    }
    }

    如果接口中包含/api_100这个接口时的配置文件
    module.exports = {
    proxy: {
    '/api_100': {
    target: 'http://192.168.1.10/web_test/index.php',
    secure: false,
    changeOrigin: true, // 是否跨域
    }
    }
    }

     3.上述配置代表,在发请求http://192.168.1.10/web_test/index.php/api2_100/login的时候就可以写成/api_100/login,就能代理成功。

  • 相关阅读:
    a 超链接标签
    select(下拉标签和textarea(文本框)
    input标签
    input 标签
    div 标签
    body 标签
    STL__网上资料
    STL_iterator返回值
    STL_算法_中使用的函数对象
    STL_std::iterator
  • 原文地址:https://www.cnblogs.com/fairy62/p/10930361.html
Copyright © 2011-2022 走看看