CORS not working while passing data via POST form fields

I'm creating simple API using coldfusion taffy framework. I've enabled the CORS in my app settings even though I'm getting a "CORS preflight channel did not succeed" issue while calling the POST method.

But I found something it's strange to me. When I call the POST method by passing the data via URL. For example like this, it's working fine without issues

http://sample.com/api/cont/?attributes={'name':'test','email':'[email protected]','cpInfo':null,'phone':'sample','companyName':'company','comments':'I%27ve+tested+the+cors+domain.com'}&functionName=doContactSales

When I call the same POST method by passing the data in form fields. I'm getting this issues "CORS preflight channel did not succeed"

http: //sample.com/api/cont/

attributes='name':'test','email':'[email protected]','cpInfo':null,'phone':'sample','companyName':'company','comments':'I%27ve+tested+the+cors+domain.com'}

functionName=doContactSales

I've added these headers in the response.

response.setHeader("Access-Control-Allow-Origin","http://www.sample.com" );
response.setHeader("Access-Control-Allow-Methods", "#verb#, OPTIONS" );
response.setHeader("Access-Control-Allow-Headers", "accept, Origin, application/json, X-Requested-With, Content-Type, Access-Control-Allow-Origin" );               
response.setHeader("Access-Control-Max-Age", "86400" );

Please let me know Why I'm getting "CORS preflight channel did not succeed" on passing the data via form fields. And how to fix it out.

Upvotes: 2

Views: 301

Answers (0)

Related Questions