CORS Request(POST) - Custom Header doesn't work

Highlighted
One Star

CORS Request(POST) - Custom Header doesn't work

Hi,
I made a REST API (POST) for create a new ressource in the Database, and it works when I test it with Firefox RestClient.
But when I try to call the API from a web application, I got a CORS error. I tried to set custom headers in the tRestresponse's advanced setting, and got the pre-flight response (OPTIONS) which is 200 OK, but looking at its header, I didn't found what I set in the component tRestresponse. It seems that what I set is not valide.
So the question is: how to enable CORS for API (POST)?
Thanks in advances!
Moderator

Re: CORS Request(POST) - Custom Header doesn't work

Hi,
Are you using tRESTRequest? Could you please take a look at a jira issue:https://jira.talendforge.org/browse/TESB-10065 to see if it is what you are looking for?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.

Re: CORS Request(POST) - Custom Header doesn't work

I have the same issue and I am not using tRESTRequest. The client application makes a preflight request and the response is missing my custom headers. I am using Talend ESB Open Source 6.1.1. Is there a solution for this?

Re: CORS Request(POST) - Custom Header doesn't work

I ended up figuring out how to fix the issue. In tRESTRequest you have to create a separate entry with the same URL that uses the HTTP Verb OPTIONS. Then configure your headers to set the required CORS headers.
This is only required if your client application creates preflight requests.

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Why Companies Move to the Cloud: 7 Success Stories

Learn how and why companies are moving to the Cloud

Read Now