MarkLogic HTTP Server: Set up CORS headers

泪湿孤枕 提交于 2019-12-10 13:46:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!