为什么我在Vue.js中收到ERR_CONNECTION_TIMED_OUT?

g m*_*iou 6 frontend vue.js vue-cli-3

使用vue cli 3创建新项目后,出现以下错误:

GET http://192.168.1.13:8080/sockjs-node/info?t=1538257166715 net :: ERR_CONNECTION_TIMED_OUT sockjs.js?9be2:1605

作业系统:Windows 10

Ale*_*ikh 8

使用以下代码创建vue.config.js:

module.exports = {
devServer: {

    host: 'localhost'
    }
};
Run Code Online (Sandbox Code Playgroud)

https://cli.vuejs.org/config/#devserver


Eri*_*num 6

To expand on Alexey's answer...

If your frontend app and the backend API server are not running on the same host, you will need to proxy API requests to the API server during development. This is configurable via the devServer.proxy option in vue.config.js. https://cli.vuejs.org/config/#devserver

module.exports = {
  devServer: {
    proxy: 'http://localhost:8080'
  }
}
Run Code Online (Sandbox Code Playgroud)