Use nginx simple solution to cross-domain

Use nginx solve cross-domain

1. Download nginx nginx Download: http://nginx.org/en/download.html , after download, enter the following directory nginx nginx -v, if the version number appears, the installation was successful.

 

Nginx file in the terminal, using the Start command starts nginx nginx; or double-clicking the file nginx.exe nginx file. Nginx to start, entered in the browser HTTP: // localhsot: 80 , if the following screen appears, indicating nginx has been successfully installed.

 

2. Use nginx reverse proxy to solve cross-domain

Front-end code:

Use axios transmission request.

 

 

 3. nginx conf directory of the directory file nginx.conf, as follows:

 

In nginx file terminal, using nignx -s reload command to restart nginx.

4. I will because the project directly on the html directory nginx directory, enter the browser http: // localhsot: 80 can access the access project.

 

Guess you like

Origin www.cnblogs.com/lxz123/p/12541266.html