vue 中的 跨域问题

版权声明:本文为博主原创文章,转载请附上出处。 https://blog.csdn.net/k_runtu/article/details/82634572

可以先参考这里, 这里把vue中跨域的原理讲清楚了,只是有两点需要注意

proxyTable: {
        '/api': {
            target: 'http://localhost:3000',
            changeOrigin: true,
            // pathRewrite: {
            //     '^/api': '/api'
            // }
        }
    },
  1. target不需要再加/api, ‘^api’: ‘/api’ 是默认的,可以不写
  2. 最后不需要在配置文件中加 –open, 那只是在编译完后自动在浏览器中打开首页地址

猜你喜欢

转载自blog.csdn.net/k_runtu/article/details/82634572