Question
· Apr 1, 2017

How to enable CORS in Cache Rest Services

Hi

I tried to access one server to another server in Cache Rest Service, I tried 

Parameter HandleCorsRequest = 1;

and

<Route Url="/data/:first/:second" Method="GET" Call="GetData" Cors="true"/>

But not working,

Can anyone tell me the solution??

Thanks in advance!!

Discussion (5)0
Log in or sign up to continue

You can put some code in the OnHandleCorsRequest to debug or monitor the CORS handling :

/// This is the CORS request handler. User should override this method in their subclass
/// if they don't want the default behavior
ClassMethod OnHandleCorsRequest(pUrl As %String) As %Status
{
    #; The default implementation is simply to dispatch to the
    #; default handler
    Set tOrigin=$Get(%request.CgiEnvs("HTTP_ORIGIN"))
    Set ip = $Get(%request.CgiEnvs("REMOTE_ADDR"))
    Set method = $Get(%request.CgiEnvs("REQUEST_METHOD"))
    set ^debug($i(^debug))=$lb($ZD($H,8),$ZT($P($H,",",2)),pUrl,tOrigin,ip,method)
    Quit ..HandleDefaultCorsRequest(pUrl)
}