I am making an ajax call to server like below:
$.ajax({
type : "POST",
dataType : "json",
url : url+ "/oms/rest/XYZ/anon/uvw/grantAbc",
data : {
"username" : username,
"password" : password
},
But on server side it's failing because origin:file:// getting sent with rest call.

You cannot change the origin from file:// because you literally have no origin. The issue is that your REST back-end does not allow file:// as origin. You need to change that in your back-end.