Frequently Asked Questions

How to solve the problem if CORS (Cross-Origin Resource Sharing) occurs when App uses Ajax XmlHttpRequest?

Category: Technical FAQ

webOS TV follows the CORS (Cross-Origin Resource Sharing) standard. We only provide the method to control the access in the server.

Find out more about CORS on the enable-cors website.

You can refer to the following sites or other Google sites.
Cross-Origin Resource Sharing (CORS)
CORS Filter
Servers that supports CORS?

In case of JSP

Add the following at the JSP code of the service part.

Access-Control-Allow-Origin: allow domain
Access-Control-Allow-Methods: POST, GET, OPTIONS
Access-Control-Allow-Headers: Content-Type, Accept, x-requested-with
Access-Control-Max-Age: 1728000

As a result, jsp code should look like this:

response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS");
response.setHeader("Access-Control-Allow-Headers", "Content-Type, Accept, x-requested-with");
response.setHeader("Access-Control-Max-Age", "1728000");

Apache Server

  1. Open httpd.conf file under the conf folder at Apache server.

  2. Modify "#LoadModule headers_module modules/mod_headers.so" into "LoadModule headers_module modules/mod_headers.so".

  3. Add the following at the end.

    Header set Access-Control-Allow-Origin "*"

    “*” means that access from any website is allowed. To allow a specific website only, use the form like "www.anysite.com".

To avoid cross domain issue, try using JSONP.