Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to add other proxies to the vue proxytable proxy root path at the same time

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article "vue proxytable proxy root path how to increase other agents at the same time" most people do not understand, so the editor summarized the following content, detailed, clear steps, with a certain reference value, I hope you can get something after reading this article, let's take a look at this "vue proxytable proxy root path how to add other agents at the same time" article.

Add other proxies at the same time of proxytable proxy root path

The Vue project has a requirement that the root path'/ 'needs to be proxied, but there are also access requirements for other special paths' / py', example:

Agent / * to localhost:5000

Agent / py/* to localhost:5001

At this point, you need to write the proxy of the special path in front of the root path, otherwise it will be overwritten by the proxy of the root path and cannot be proxied successfully:

Module.exports = {dev: {proxyTable: {'/ py': {target: `localhost: 5001`, changeOrigin: true, pathRewrite: {'/ py':',}},'/': {target: `localhost: 5000`, / / secure: true, / / whether https changeOrigin: true / / whether it is a cross-domain request} proxyTable: {undefined'/list': {undefinedtarget: 'http://api.xxxxxxxx.com',changeOrigin: true,pathRewrite: {' ^ / list':'/ list'}

In this way, when we write url, we only need to write / list/1 to represent api.xxxxxxxx.com/list/1

The default pathRewrite for proxytable is pathRewrite: {'^ / api':''}

So when we write url, we can write / api/1 to represent api.xxxxxxxx.com/1.

Note:'/ api' is the match and target is the requested address. Because the url of ajax is prefixed with'/ api', 'and the original interface does not have this prefix, you need to rewrite the address through pathRewrite to convert the prefix' / api' to'/'. If the interface address itself has the universal prefix'/ api'', you can delete the pathRewrite.

ChangeOrigin parameter, if set to true, then a local server will receive your request and send it on your behalf, so that there will be no cross-domain problems.

In addition: proxytable is only used in the development environment

The above is about the content of this article on "how to add other agents to the vue proxytable proxy root path at the same time". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report