MarkLogic - CORS与REST API [英] MarkLogic - CORS with REST API

查看:221
本文介绍了MarkLogic - CORS与REST API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于MarkLogic的Web应用程序,它有两个来源中提取数据,文档存储和三店我MarkLogic服务器上都主持。该应用程序使用MarkLogic内置的REST API来访问这些数据存储。文档存储的REST API在端口8003上运行,并三联门店的REST API是在端口8007.该应用程序的文档存储的模块数据库托管。现在,当我做一个REST API调用来拉三重数据,我得到一个异常称访问控制允许来源头没有设置在服务器端。我想知道我可以设定,让我得到了来自REST API的所有响应的访问控制,允许原产地'为'*'。我已阅读xdmp的文档:添加响应报头,但我无法弄清楚,我可以正确地使用它。所有的帮助是非常AP preciated!

I have a MarkLogic-based web application which pulls data from two sources, a document store and a triple store both hosted on my MarkLogic server. The app uses MarkLogic's built-in REST APIs to access these data stores. The document store's REST API is running on port 8003 and the triple store's REST API is on port 8007. The application is hosted on the modules database of the document store. Now, when I make a REST API call to pull triple data, I get an exception saying the 'access-control-allow-origin' header has not been set at the server side. I would like to know how I can set it up so I get 'access-control-allow-origin' as '*' in all responses from the REST API. I have read the documentation on xdmp:add-response-headers, but I'm not able to figure out where I can use it correctly. All help is much appreciated!

谢谢!

推荐答案

为什么不保持在同一个数据库中的文档和三倍?做到这一点的能力是MarkLogic的优势之一。

Why not keep the documents and triples in the same database? The ability to do that is one of MarkLogic's strengths.

内置的REST API终点似乎不支持任何机制将任意的响应头。 的https:但是写一个REST扩展时,你应该能够添加自己的头//文档.marklogic.com /引导/休息-dev /目录扩展

The built-in REST API endpoints don't seem to support any mechanism for adding arbitrary response headers. However you should be able to add your own headers when writing a REST extension: https://docs.marklogic.com/guide/rest-dev/extensions

有关内置端点可以考虑通过路由另一个应用服务器层,或透明反向代理请求。从而使浏览器认​​为这两个REST API实例都在同一台服务器上无论哪种方式的目标是重新路由请求。

For the built-in endpoints you might consider routing requests through another app-server layer, or a transparent reverse proxy. Either way the goal would be to re-route requests so that the browser thinks both REST API instances are on the same server.

这篇关于MarkLogic - CORS与REST API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆