ENABLE CROSS-DOMAIN
Browser does not allow cross domain AJAX requests due to security issues. Cross-domain requests are allowed only if the server specifies same origin security policy.
To enable CORS, You need to specify below HTTP headers in the server.
- Access-Control-Allow-Origin – Name of the domain allowed for cross domain requests. * indicates all domains are allowed.
- Access-Control-Allow-Methods – List of HTTP methods can be used during request.
- Access-Control-Allow-Headers – List of HTTP headers can be used during request.
header("Access-Control-Allow-Credentials: true");
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
header('Access-Control-Max-Age: 1000');
header('Access-Control-Allow-Headers: Content-Type, Content-Range, Content-Disposition, Content-Description');
In JAVA, you can use the below code to set the headers.
header("Access-Control-Allow-Origin: *");
Comments
Post a Comment