webpack 配置代理失败 遇到ENOTFOUND

40 阅读1分钟

错误信息

Error [HPM] Error occurred while trying to proxy request / from localhost:8000 to  
10.168.30.187:9031
(ENOTFOUND)

错误的

{  
    '/tpf/api': {  
        target: '10.168.30.187:9031', // Replace with your API endpoint  
        headers: {  
            SESSION_PARAMS: '0099|0099'  
        },  
    },  
}

target 需要包括 http:// 这样的协议头

正确的

{  
    '/tpf/api': {  
        target: 'http://10.168.30.187:9031', // Replace with your API endpoint  
        headers: {  
            SESSION_PARAMS: '0099|0099'  
        },  
    },  
}