javascript - Interface for aggregating data, how to configure proxyTable and how to write target and pathRewrite?
某草草
某草草 2017-05-19 10:36:02
0
2
787

I want to call the interface for aggregating data, but the configuration is wrong. Please help me find out what's going on.
What is the difference between '^/api': '/api' and '^/api': ''. I just learned it and don’t quite understand it.

The address of my request is: http://v.juhe.cn/movie/index?...

How can I correct my mistake?

某草草
某草草

reply all(2)
为情所困

proxyTable: {
'/xxx': {

target: '正式网址',
changeOrigin: true

}
}

xxx refers to the public part of the URL you send to the backend. You will use this character in almost every interface.
Then after matching, the localhost part of the address you want to send will be replaced with the target field (official URL),
As for RewritePath, it redirects the request for the resource to another path, making it different from the path indicated by the requested URL.
Whether you want to add it depends on the requirements

After reading your situation, I suggest you ask the backend if there is such a request interface, because you are reporting a 404 error and cannot find this interface, rather than a cross-domain problem

黄舟
proxyTable: {
  '/api': {
    target: 'http://v.juhe.cn',
    changeOrigin: true,
    pathRewrite: {
      '^/api': ''
    }
}

Only available in webpackDevServer environment

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!