Webpack dev server always reports error 404 when configuring reverse proxy. How to solve it?
Error log: GET http://localhost:8080/mzabris... 404 (Not Found)
Configuration file:
devServer: {
inline: true,
noInfo: true,
port: 8080,
proxy: {
'/mzabriskie': {
target: 'https://github.com',
changeOrigin: true
}
}
},
Interface code:
this.$http.get('/mzabriskie/axios').then((response) => {
console.log(response)
}).catch((error) => {
console.log(error)
})
phpcn_u15822017-05-18 11:03:53
There seems to be nothing wrong with the configuration, mainly because I seem to have written the wrong file....
怪我咯2017-05-18 11:03:53
There is absolutely no problem with your code...Have you restarted webpack after modifying the configuration?
滿天的星座2017-05-18 11:03:53
Add a line
proxy: {
'/mzabriskie': {
target: 'https://github.com',
changeOrigin: true,
'/mzabriskie': '/mzabriskie'
}
}
Then restart webpack