Vue axios request to automatically bring the current domain name?

clipboard.png

clipboard.png

clipboard.png

ask for answers from all kinds of gods


this is not the same concept as proxytable, proxytable is just a cross-domain processing scheme under dev (node environment).
if it is a production environment, nginx/apache is generally used to proxy the domain name port to be consistent with the URL of the front-end static file. In the
code, you don't need a domain name when you use axios to request an API such as / path/resturl . When you request an interface like < domain > / path/resturl < / domain >, you will naturally bring the domain name and port of the browser's URL address.
in this way, under dev, you no longer need to replace the domain name of the interface in the code when you deploy in the proxytable; production environment.


are you.

http: / / 127.0.0.1/xxx/xxxx lost both bars


request address is written as a relative path, right?
localhost/xxxxxx
preceded by http (s): / / or /


is not the current domain name automatically brought by vue, but by the browser.


when encapsulating axios request, add baseURL


Menu