鍍金池/ 問答/Java  PHP  HTML/ http://localhost:8000/user請(qǐng)求成http://loca

http://localhost:8000/user請(qǐng)求成http://localhost:8000/server/user

proxyTable: {

  '/server': {
        target: 'http://localhost:8000/', // 接口的域??
        // secure: false,  // 如果是https接口,需要配置這個(gè)參??
        changeOrigin: true, // 如果接口跨域,需要進(jìn)行這個(gè)參數(shù)配??
        // pathRewrite: {
        //   '^/api': ''
        // }
    }

    '/user': {
        target: 'http://localhost:8000/user/register', // 接口的域??
        secure: true,  // 如果是https接口,需要配置這個(gè)參??
        changeOrigin: true, // 如果接口跨域,需要進(jìn)行這個(gè)參數(shù)配??
        // pathRewrite: {
        //   '^/api': ''
        // }
    },
    
    }
回答
編輯回答
淡墨

localhost:800還是localhost:8000呢?
還有我不太理解為什么把第二個(gè)的secure設(shè)為true,從代碼上來看,你只是鏈接到了http的接口呀

2018年8月7日 15:43
編輯回答
乖乖噠

后端接口地址是 /server/user/register,前端請(qǐng)求的時(shí)候url地址寫 /server/user/register,

'/server': {
target: 'http://localhost:8000', // 后端服務(wù)地址,注意 端口號(hào)后面沒有 /
changeOrigin: true
}
2017年9月8日 14:03