解决axios请求百度Ai接口跨域问题

环境:vueCli4+vue2.x+vuerouter
新建vue.config.js文件添加以下配置

module.exports = {
    
    
    devServer: {
    
    
        proxy: {
    
    
            '/api': {
    
    
                //  target: 'http://127.0.0.0:8080',
                target: 'https://aip.baidubce.com',
                changeOrigin: true,
                pathRewrite: {
    
    
                    '^/api': ''
                }
            }
        }
    }
}

猜你喜欢

转载自blog.csdn.net/qq_42107364/article/details/116891129