问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/24270088/marklogic-http-server-set-up-cors-headers