MarkLogic HTTP服务器:设置CORS头 [英] MarkLogic HTTP Server: Set up CORS headers
问题描述
我在 CentOS 6.5盒
上运行 MarkLogic 7
。我有在同一台机器上的MarkLogic HTTP服务器上托管的 HTML / JS
应用程序。应用程序在端口8003上运行,需要通过在不同端口8007上运行的 REST API
访问数据。当我使用 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.
有任何人为 c $ c> CORS
更早?任何帮助将是巨大的。
Has anyone set up MarkLogic
for CORS
earlier? Any help would be great.
推荐答案
您可以使用 https://docs.marklogic.com/xdmp:add-response-header 设置 Access-Control-Allow-Origin
标头。您必须为需要使用跨网站请求的每个端点执行此操作: https://developer.mozilla.org/zh-CN/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.
这篇关于MarkLogic HTTP服务器:设置CORS头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!