Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MarkLogic HTTP Server: Set up CORS headers

I am running MarkLogic 7 on a CentOS 6.5 box. I have my HTML/JS application hosted on a MarkLogic HTTP server on the same machine. The application runs on port 8003, and needs to access data through a REST API running on a different port 8007. When I use an AJAX request in my application, I get an error saying

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://172.16.100.104:8003' is therefore not allowed access.  

Has anyone set up MarkLogic for CORS earlier? Any help would be great.

like image 894
Krishna Chaitanya Avatar asked Oct 31 '22 21:10

Krishna Chaitanya


1 Answers

You can use https://docs.marklogic.com/xdmp:add-response-header to set the Access-Control-Allow-Origin header. You'll have to do that for every endpoint that needs to use cross-site requests: https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS has details.

like image 150
mblakele Avatar answered Nov 24 '22 09:11

mblakele