我在我的自定义休息端点中设置了“Access-Control-Allow-Origin”,但是当我从 javascript 调用这个 web 服务时,我收到以下错误
XMLHttpRequest cannot load http://10.239.12.22:8042/LATEST/resources/repoUIFacet?rs:q=TNF. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://gprulcd707873.abbvienet.com:8000' is therefore not allowed access. The response had HTTP status code 401.
以下是我设置响应标头的代码
(: Function responding to GET method - must use local name 'get':)
declare function repoUIFacet:get($context as map:map, $params as map:map) as document-node()*
{
let $output-types := map:put($context,"output-types","application/json")
let $_ := xdmp:add-response-header("Access-Control-Allow-Origin", "*")
...
};
如何设置 OPTIONS 请求的响应标头?