zoukankan      html  css  js  c++  java
  • 4.Vue跨域session问题解决

    1.设置koa2服务器从本地代理转发
    修改:项目/config/index.js-->dev中
    proxyTable: {
    '/api': {
    target: 'http://localhost:3000',
    changeOrigin: true,
    pathRewrite: { //需要rewrite重写的, 如果在服务器端做了处理则可以不要这段
    '^/api/': ''
    }
    }
    },

    //--------------------------------------------------
    dev: {
    env: require('./dev.env'),
    port: 8080,
    autoOpenBrowser: true,
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    proxyTable: {
    '/api': {
    target: 'http://localhost:3000',
    changeOrigin: true,
    pathRewrite: { //需要rewrite重写的, 如果在服务器端做了处理则可以不要这段
    '^/api/': ''
    }
    }
    },
    //--------------------------------------------------

    2.axios访问路径改为:
    axGet('/api/hall/getRoomList',{},function(res){
    alert(res.data);
    },function(err){
    alert(err);
    });

    3.一定要重启vue服务器

  • 相关阅读:
    MvvmTest
    win8 app 相关的几个网站
    autp
    分析WPF代码工具
    mdsn
    线程和委托
    C#guanli
    学习Boost小结(一)
    Boost.test库的配置
    自己真是太没正事了.
  • 原文地址:https://www.cnblogs.com/xintao/p/9990183.html
Copyright © 2011-2022 走看看