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!!
Should be enough.
Anyway, what error are you getting?
This error I got
HttpRequest cannot load
http://localhost:57772/api/project.
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:57773
' is therefore not allowed access. The response had HTTP status code 401.You need to give access to the web-application.
/// 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)
}
Still having problems ?
Try something like this...
Before your application response !