| 52 | |
---|
| 53 | === Useful Tip === |
---|
| 54 | |
---|
| 55 | This is mainly about CORS (Cross Origin Resource Sharing). If you have an ADEI setup at your localhost, and you wrote a javascript to fetch data directly from your localhost ADEI, 99% of the time you will be thrown this error: |
---|
| 56 | |
---|
| 57 | Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://127.0.0.1/adei/services/getdata.php?db_server=wtx_060&db_name=HDCP2&db_group=base&window=1364919175-1364919176&db_mask=0,1,2,3,4,5. This can be fixed by moving the resource to the same domain or enabling CORS. |
---|
| 58 | |
---|
| 59 | When you stumbled upon this, firstly, take a deep breath. Then you must know which server you are trying to talk to. In this case, we are trying to getdata from localhost. And ADEI server is basically Apache server. |
---|
| 60 | |
---|
| 61 | what does this tell us? Our localhost server is not allowing any remote access to get resources, which is set by default to prevent malicious attacks. We need to tell our apache server to allow this. |
---|
| 62 | |
---|
| 63 | So. |
---|
| 64 | |
---|
| 65 | Add this line |
---|
| 66 | |
---|
| 67 | Header set Access-Control-Allow-Origin "*" |
---|
| 68 | |
---|
| 69 | into your .htaccess |
---|
| 70 | |
---|
| 71 | and then run |
---|
| 72 | |
---|
| 73 | apachectl -t |
---|
| 74 | sudo service apache2 reload |
---|
| 75 | a2enmod headers |
---|
| 76 | |
---|
| 77 | after that it should work. Link: http://enable-cors.org/server_apache.html |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | |
---|