Hi,
I am trying to enable the CORS on the web dev module, but I am not able to get it working. I have set up the CORS headers in the doOptions method, but I am still encountering the same CORS issue on the frontend. Additionally, I copied the web dev endpoint example from the Github, but I am facing the same issue.
The code I used in the doOptions method is as follows:
I managed to enable CORS in my WebDev doGet() with the below codes.
Hope this will help you too.
#modify response headers
servletResponse = request["servletResponse"]
servletResponse.addHeader("Access-Control-Allow-Origin", "*") #allow API calls from other hosts in addition to that of the gateway
tag = system.tag.readBlocking(['[default]zTest/int2'])[0].value
json = {'tag': tag}
return {'json': json}
#This response can be retrieved with fetch() in JavaScript.