Solve the cross-domain problem when accessing external URLs in nginx:

I got an error when I initiated a get request on my server today (I didn’t take a screenshot at the time, so I just found a picture online and the error was the same)

 It is said that it is because there is no setting to allow cross-domain request access.

The solution is as follows:

First log in to my server and enter the system (Linux system)

Add this line of code here to allow cross-domain

After saving, return to the usr/local/nginx/sbin directory

./nginx -t Check whether there are file configuration abnormalities

 This error is because the conf file does not support comments, and each sentence needs to be ended with;, which I did not add before;

This shows that it is successful, just restart nginx./nginx -s reload

Please note that there is a pitfall here. You must enter the command in the /usr/local/nginx/sbin directory to execute successfully, otherwise the following error will be reported.

 If you initiate a cross-domain request at this time, no error will be reported.  

Guess you like

Origin blog.csdn.net/p_s_p/article/details/129432476