Question
In my Tizen web application, I need to access data files from various public websites that I don't own. I attempted to use Ajax for this purpose, but I'm not receiving any response.
My application privileges are configured as follows:
<tizen:privilege name="http://tizen.org/privilege/internet"/>
<tizen:privilege name="http://tizen.org/privilege/download"/>
What am I missing in this setup? Is it necessary for the target websites to accept cross-domain requests? If cross-origin restrictions are the issue, I would need alternative solutions.
Answer
Problem Understanding
The issue involves two main challenges:
- Proper configuration of network access permissions in the Tizen application
- Potential Cross-Origin Resource Sharing (CORS) restrictions when accessing external domains
Solution Methods
-
Configure Network Access Permissions:
- Add domain access permissions in your config.xml file
- You can specify individual domains or use wildcards (*) for broader access
-
Handle CORS Restrictions:
- If the target server doesn't support CORS, consider using a proxy server
- Alternatively, if you control the server, implement proper CORS headers
Code Examples
- Basic domain access configuration:
<access origin="http://example.com" subdomains="true"></access>
<access origin="http://anothersite.com" subdomains="true"></access>
- Wildcard access (use with caution):
<access origin="*" subdomains="true"></access>
Additional Tips
- Always specify the exact domains you need rather than using wildcards when possible for better security
- For CORS-related issues, refer to the official documentation at Samsung Tizen OS CORS Guide
- Test your application with different domain configurations to find the most secure setup that meets your requirements