编程知识 cdmana.com

Summary of front end development-1

vue Cross-domain problem

     Use vue Access is denied when a request is sent to a different port , Because this is “ Cross domain ” Of , By default vue Cross domain access is not allowed .<br>      open vue Under project directory config/index.js, find proxyTable Location , Add the following :<br> proxyTable : {<br> '/api' : { // To cross domain url Location , It's like you're going to /api/** Send a request , among /api No prefix before ,/api/ After that, everything will be recognized .<br> target : 'http://ip:port' // Map to target ip Or the domain name <br> pathRewrite: {<br> ^/api/' :"" // take /api Mapping to white space , It can also be mapped to other strings , for example :/api/1 => /1, Plus the front target=》http://ip:port/1<br> },<br> changeOrigin:true // Allow cross-domain <br> }<br> }<br> }<br>

版权声明
本文为[xxhhxhh]所创,转载请带上原文链接,感谢

Scroll to Top