Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
litespeed_wiki:config:cors [2017/10/09 14:11]
Lisa Clarke [Before verification]
litespeed_wiki:config:cors [2017/10/09 14:21]
Lisa Clarke [Method 2: Set from config]
Line 20: Line 20:
 ==== Method 2: Set from config==== ==== Method 2: Set from config====
 Navigate to **Web Admin > Configurations > Your Virtual Hosts > Context**: Navigate to **Web Admin > Configurations > Your Virtual Hosts > Context**:
-  - Click **Add** button +  - Click the **Add** button 
-  - Choose ​**Static** type+  - Choose ​''​Static'' ​type
   - Set **URI** to ''/''​ (You can change this if you want to)   - Set **URI** to ''/''​ (You can change this if you want to)
   - Set **Location** to ''​$SERVER_ROOT/​Example/​html/''​ (You can change this if you want to)   - Set **Location** to ''​$SERVER_ROOT/​Example/​html/''​ (You can change this if you want to)
Line 36: Line 36:
 Check that our response header includes ''​Access-Control-Allow-Origin *''​. \\ {{:​litespeed_wiki:​config:​cors-6.png?​600|}} \\ Check that our response header includes ''​Access-Control-Allow-Origin *''​. \\ {{:​litespeed_wiki:​config:​cors-6.png?​600|}} \\
 ==== Start verification==== ==== Start verification====
-Test CORS is [[https://​stackoverflow.com/​questions/​12173990/​how-can-you-debug-a-cors-request-with-curl | not easy]], here we are going to use [[http://​www.test-cors.org | Test-cors online tool]] to verify it with simple ​step.\\ +Testing ​CORS is [[https://​stackoverflow.com/​questions/​12173990/​how-can-you-debug-a-cors-request-with-curl | not easy]], here we are going to use [[http://​www.test-cors.org | the Test-cors online tool]] to verify it with simple ​steps.\\ 
-Tool shows like this, basically we need to enter in **HTTP Method** and Target **Remote URL** \\ {{:​litespeed_wiki:​config:​cors-3.png?​600|}}\\ +The tool looks like this. We need to enter the **HTTP Method** and Target **Remote URL** \\ {{:​litespeed_wiki:​config:​cors-3.png?​600|}}\\ 
-  * Send with default supported method, e.g. ''​GET'':​ \\ {{:​litespeed_wiki:​config:​cors-4.png?​600|}} \\ +  ​* **Send Request** ​with the default supported method, e.g. ''​GET'':​ \\ {{:​litespeed_wiki:​config:​cors-4.png?​600|}} \\ 
-  * Send with default ​unsupported method, e.g. ''​DELETE'':​ \\ {{:​litespeed_wiki:​config:​cors-5.png?​600|}} \\ +  ​* **Send Request** ​with an unsupported method, e.g. ''​DELETE'':​ \\ {{:​litespeed_wiki:​config:​cors-5.png?​600|}} \\ 
-  * You can also copy the code from testing tool to test by your own\\ <​code>​+  * You can also copy the code from the testing tool to test on your own\\ <​code>​
 var createCORSRequest = function(method,​ url) { var createCORSRequest = function(method,​ url) {
   var xhr = new XMLHttpRequest();​   var xhr = new XMLHttpRequest();​
Line 71: Line 71:
 xhr.send(); xhr.send();
 </​code>​ </​code>​
-==== How to support more method ​==== +==== How to support more methods ​==== 
-Default ​CORS support method: PUSH, GET and HEAD. What if want to support ​**OPTIONS** and **DELETE**? \\+By default, ​CORS supports the following methods''​PUSH''​''​GET'' ​and ''​HEAD''​. What if you want to support ​''​OPTIONS'' ​and ''​DELETE'',​ as well? \\
 === Method 1: Set from htaccess file=== === Method 1: Set from htaccess file===
-You can simply append ''​Header always set Access-Control-Allow-Methods:​ <​nowiki>"​GET,​POST,​OPTIONS,​DELETE"</​nowiki>''​ to .htaccess file+You can simply append ''​Header always set Access-Control-Allow-Methods:​ <​nowiki>"​GET,​POST,​OPTIONS,​DELETE"</​nowiki>''​ to the ''​.htaccess'' ​file
  
  
 === Method 2: Set from config=== === Method 2: Set from config===
-You can simply append **Extra Headers** ''​Access-Control-Allow-Methods GET, POST, OPTIONS, DELETE''​. \\ {{:​litespeed_wiki:​config:​cors-7.png?​|}} \\+You can simply append ​to **Extra Headers**''​Access-Control-Allow-Methods GET, POST, OPTIONS, DELETE''​. \\ {{:​litespeed_wiki:​config:​cors-7.png?​|}} \\
  
  
-You can try verification again with sending **DELETE** HTTP method. You will see 200 response. \\ {{:​litespeed_wiki:​config:​cors-8.png?​|}} \\+If you try verification again with the ''​DELETE'' ​HTTP method, you should ​see the 200 response. \\ {{:​litespeed_wiki:​config:​cors-8.png?​|}} \\
  
 ===== More Information ===== ===== More Information =====
  • Admin
  • Last modified: 2017/10/09 14:21
  • by Lisa Clarke