After establishing a project about Vue frame, how is the problem that cracks interface of butt joint back end had when Build project

Vue-cli4 project, I had had a function at present complete back end, node is not written, want to build front with Vue compose next. Such feeling is when so I am updating code: Back end moves in 127.0.0.1:8081, front runs in 127.0.0.1:8 with the Serve function of Vue-cli080, added in the configuration file of Vue so a paragraph:

module.exports = {
  devServer:{
    host:\'0.0.0.0\',
    proxy:{
      \"/api\":{
        target:\"http://127.0.0.1:8081\",
        changeOrigin:true,
        pathRewrite:{
            \'^/api\':\'\'
        }
      }
    }
  },
}

After such settings if I have address of interface of a back end,be 127.0.0.1:8081/json/get_test

In Vue I need to be written into Src=\”/api/json/get_test\” only, with respect to function of OK and normal use interface, and be solved automatically straddle region issue.

Next the issue came, the project is written now, I want Build and go running in the engine that takes other language. All request addresses still keep unvarnished after moving Npm Run Build, instead does not have a law to receive on interface

How should be this kind of circumstance configured?

Related Posts

7 thoughts on “After establishing a project about Vue frame, how is the problem that cracks interface of butt joint back end had when Build project

  1. DevServer just as its name implies is the representative below Dev environment, convenient development uses, the postposition representative that produces an environment to must configure the API on region server by oneself

  2. Vue Cli is OK infuse environment is variable, whether is the basis is judged development environment, it is to develop an environment to be added / Api

  3. @xuanloe
    @rockjike
    @robinlovemaggie
    How is manufacturing environment configured? My hope serves interface to be formerly namely / Json/get_test, when developing, can work normally, when compiling can replace the address of development automatically time / Json/get_test is not / Api/json/get_test

Leave a Reply

Your email address will not be published. Required fields are marked *