You can achieve this in the controller using:
request.headers['origin']
Note. You will need to make certain changes to certain configuration files for your application in order to be able to respond to a CORS request. I hope you have it covered.
Ritikesh
source share