MarkLogic HTTP服务器:建立CORS头服务器、MarkLogic、HTTP、CORS

2023-09-10 19:47:25 作者:吐槽大神

我在一个CentOS 6.5中运行MarkLogic 7。我有我的HTML / JS应用程序托管在同一台机器上的MarkLogic HTTP服务器上。该应用程序在端口8003上运行,并且需要通过REST API在不同的端口8007.上运行的访问数据。当我用我的应用程序的AJAX请求,我得到一个错误说

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.  

有没有人设立MarkLogic为CORS更早?任何帮助将是巨大的。

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

推荐答案

您可以使用 HTTPS ://docs.marklogic.com/xdmp:附加响应头设置访问控制 - 允许 - 原产地头。你需要做的,对于每一个端点需要使用跨站请求:的 https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS 有更多的细节。

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.