Nginx configuration is not valid across domains!

the previous project (front and rear separation) is that the verification code and data acquisition are normal on the apache server!

then switch to nginx server result graphics CAPTCHA cannot be verified! But there is nothing wrong with getting and submitting data!

then configure it in the server configuration

add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers X-Requested-With;
add_header Access-Control-Allow-Methods GET,POST,OPTIONS;

Don"t say the CAPTCHA code after configuration, and even prompt to get the data

Response to preflight request doesn"t pass access control check: The "Access-Control-Allow-Origin" header contains multiple values "http://localhost:9080, *", but only one is allowed. Origin "http://localhost:9080" is therefore not allowed access.

is there any way to solve it?

Sep.08,2021

prompt is clearly written, Allow-Origin that does not allow multiple values.


nginx Access-Control-Allow-Origin
then you can remove (delete) Access-Control-Allow-Origin from the code
which obviously repeats

Access-Control-Allow-Origin: *

means that you have made the resource accessible to all domain names, so you don't have to use nginx proxy to cross-domain, just request it

.

it is recommended to translate the error prompt. It is very clear that Access-Control-Allow-Origin allows only one value


Thank you for my opinion.
the question of the error prompt has been made very clear on the previous floor, so I won't repeat it any more. The Apache configuration can run but the Nginx is stuck. I think we should first compare the similarities and differences between the two configurations instead of focusing on cross-domain (unless you are sure it is a cross-domain problem). In addition, even if it is really cross-domain, I think it would be more comfortable to use a proxy solution than to add a cross-domain header.


Access-Control-Allow-Origin can only write one domain name. In reality, what should I do if I want to allow multiple client domain names? Solving, I think is a very common requirement!

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e93fc0-4725b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e93fc0-4725b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?