we’re calling from domain carshipit.com and getting CORS error, the error is not present on localhost.
CAN WE call from any domain other than localhost, sand box environment, do we have to register/set/preset safe url or something else domain related in order to do that?
updated code
dwolla.configure({
environment: “sandbox”,
styles: “/Content/Dwolla.css”,
success: (result) => Promise.resolve(saveDwollaCustomer(result)),
error: (err) => Promise.resolve(alert(“Something went wrong. Please contact support. Error:” + err.response.message)),
tokenUrl: “/Dwolla/TokenUrl”
});
[HttpPost]
public async Task TokenUrl(TokenRequestModel body)
{
try
{
// Serialize the provided TokenRequestModel into JSON and create a StringContent.
// var content = new StringContent(JsonConvert.SerializeObject(body), System.Text.Encoding.UTF8, “application/json”);
// Generate a client token by calling the GenerateClientTokenWithBody method.
var clientTokenRes = await _tokenService.GenerateClientTokenWithBody(body);
// Return an Ok response with the generated client token.
return Json(new { clientTokenRes.Token }, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
// Handle errors and return a BadRequest response with an error message.
return Json(new { error = ex.Message });
}
}
public async Task GenerateClientTokenWithBody(TokenRequestModel body)
{
RestClient client = new RestClient(clientTokens)
{
//Authenticator = new HttpBasicAuthenticator(clientId, clientSecret)
};
var request = new RestRequest(Method.POST);
request.AddHeader(“Content-Type”, “application/json”);
request.AddJsonBody(body);
var response = await client.ExecuteTaskAsync(request);
if (response.StatusCode != System.Net.HttpStatusCode.OK)
{
throw new Exception(“Failed to generate client token”);
}
if (response.StatusCode != HttpStatusCode.OK)
throw new Exception(“Dwolla failed to generate client access token!”);
return response.Data;
}