CORS and finding the origin details

When you allow access from different origins and if you would like to know from which origin the request is from, you can get that information in


Once you get the origin url, you can get the host information (i.e., without http scheme and www) using the below snippet

And just fyi, to allow requests from any origin, set the below in after_action of AppilcationController

headers[‘Access-Control-Allow-Origin’] = ‘*'
Like what you read? Give Gautam Chandra N a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.