zoukankan      html  css  js  c++  java
  • vue dev开发环境跨域和build生产环境跨域问题解决


    dev开发时解决请求跨域问题:config-index.js 配置代理
    dev: { env: require('./dev.env'), port: 8082, assetsSubDirectory: 'static', assetsPublicPath: '/', proxyTable: { '/api': { target: 'http://testw.haier.com', //后端接口地址 changeOrigin: true, //是否允许跨越 pathRewrite: { '^/api': '', //重写, } } },

     

    vue单页请求路径写法 
    this.$http.post('/api/interaction-comment/getCommentList', parms).then((response) => { response = response.data; console.log(response.data) if (response.isSuccess === true) { console.log("输出") this.currentTotal = response.data.entityCount; this.tableData = response.data.entities; } }); }

      

    npm run build部署到开发环境下的跨域解决:

    在nginx-1.12.1conf 配置文件中增加:

     location /api {
            rewrite ^/api/(.*)$ /$1 break;
                proxy_pass http://testw.haier.com;
            }
    

      

  • 相关阅读:
    linux工具-awk
    linux工具-sed
    linux工具-grep
    linux编程-bash
    linux命令-sort
    linux命令-seq
    linux命令-find
    linux命令-split
    IDEA去除xml文件中的屎黄色背景
    Rabbit 基于cloud 的配置使用结构流程
  • 原文地址:https://www.cnblogs.com/hanguidong/p/10365083.html
Copyright © 2011-2022 走看看