javascript - webpack dev server reports error 404, how to solve it?
漂亮男人
漂亮男人 2017-05-18 11:01:53
0
3
530

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)
    })
漂亮男人
漂亮男人

reply all(3)
phpcn_u1582

There seems to be nothing wrong with the configuration, mainly because I seem to have written the wrong file....

刘奇

There is absolutely no problem with your code...Have you restarted webpack after modifying the configuration?

滿天的星座

Add a line

proxy: {
        '/mzabriskie': {
          target: 'https://github.com',
          changeOrigin: true,
          '/mzabriskie': '/mzabriskie'

        }
      }

Then restart webpack

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template