How Apache configuration server cross-domain resource sharing (Cross-Origin Resource Shari

  
                  

Background: The server provides the https API to the browser ajax and allows cross-domain access:

1. httpd.conf

Remove the comment LoadModule headers_module modules/mod_headers.so< Br>

2. Modify the following configuration


conf/extra/httpd-ssl <VirtualHost> ... Header add Access-Control-Allow-Origin * Header add Access- Control-Allow-Methods "GET, POST, OPTIONS" Header add Access-Control-Allow-Headers "Content-Type" </VirtualHost>


Here you must add Header Add Access-Control-Allow-Headers "Content-Type".

The guess is because the type of client to send is application/json,

so it appears in the OPTIONS request header sent:

Access-Control-Request-Headers: Content-Type, Accept

3. Restart apache

See: http://www.w3.org/TR/cors/

Copyright © Windows knowledge All Rights Reserved