CORS option does not work!

0
I have published a REST Service and enabled the CORS for all. (Mendix version 8.18.2) But It only works for the post from mendix’s own swagger page. Any other post (from Postman, online tools or Chrome console) would not get right CORS response. If I want to add CORS information by my own microflow, what should I do to create http response header?  The response string from OPTION method’s microflow goes to the body part of  http response.    
asked
1 answers
0

Hi Josh,

It expected that Postman does not receive CORS headers since its not sending a pre-flight request. Since the request has to be done from a browser, you can use this site to mimic your request: https://www.test-cors.org/ . This will send a request to your rest service from within the browser (basically the same as from the swagger page).

 

For your second question:

To add your own CORS headers you can do it like this:

You can associate these to your HttpResponse object and they will be send as headers in the request. Please make sure to also create a custom OPTION method for the method you want to have the correct CORS response.

You can find more information about this here:
https://developer.mozilla.org/nl/docs/Web/HTTP/CORS

 

 

answered