# How to enable the CORS on the web dev module

**URL:** <https://forum.inductiveautomation.com/t/how-to-enable-the-cors-on-the-web-dev-module/74669>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [June 6, 2023, 8:51pm UTC](https://forum.inductiveautomation.com/t/how-to-enable-the-cors-on-the-web-dev-module/74669 "2023-06-06T20:51:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fmata](https://avatars.discourse-cdn.com/v4/letter/f/8e7dd6/32.png) [@fmata](https://forum.inductiveautomation.com/u/fmata)\
**Post date:** [June 6, 2023, 8:51pm UTC](https://forum.inductiveautomation.com/t/how-to-enable-the-cors-on-the-web-dev-module/74669/1 "2023-06-06T20:51:53Z")

</div>

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:

```auto
def doOptions(request, session):
 	servletResp = request['servletResponse']
	servletResp.setHeader("Access-Control-Allow-Origin", "http://localhost:3000")
	servletResp.setHeader("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS, DELETE")
	servletResp.setHeader("Access-Control-Allow-Headers", "Origin, Content-Type, Accept, Authorization, X-Requested-With")
	return {'json': {}}

```

---

<div class="post-metadata">

**Author:** ![Kevin.McClusky](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@Kevin.McClusky](https://forum.inductiveautomation.com/u/Kevin.McClusky)\
**Post date:** [June 12, 2023, 6:53pm UTC](https://forum.inductiveautomation.com/t/how-to-enable-the-cors-on-the-web-dev-module/74669/2 "2023-06-12T18:53:33Z")

</div>

If you're wanting to use the servletResponse, you'll need to

> return None

as your last line. (If you do want to return some json, you'll want to add that to the servletResponse body, instead of returning a dictionary.)

I'm not sure if that's your only issue, but I hope it points you in the right direction!

---

<div class="post-metadata">

**Author:** ![bao.nguyen](https://avatars.discourse-cdn.com/v4/letter/b/8c91f0/32.png) [@bao.nguyen](https://forum.inductiveautomation.com/u/bao.nguyen)\
**Post date:** [August 15, 2023, 3:48am UTC](https://forum.inductiveautomation.com/t/how-to-enable-the-cors-on-the-web-dev-module/74669/3 "2023-08-15T03:48:32Z")

</div>

Hi,

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.

```
