Open Closed

How do I consume external Rest API from ABP Commercial? #947


0
datarebel created

I normally consume jquery API like below, however CORS is preventing this from executing outside of my application domain. How do I enable CORS for other domains?

I get this error: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at .....

`var settings = { 'cache': false, 'dataType': "json", "async": true, "crossDomain": true, "url": "https://

$.ajax(settings).done(function (response) {
    console.log(response);

});`

2 Answer(s)
  • 0
    alper created
    Support Team

    you can use abp.ajax for ajax calls. https://docs.abp.io/en/abp/latest/UI/AspNetCore/JavaScript-API/Ajax#basic-usage

    on the other hand if you are getting error from your 3rd party API, you should add your client to that server's granted clients.

  • 0
    datarebel created

    Thanks for the response. Is there any way to disable CORS globally or on a per pagemodel view for development testing sake?

    Cheers, Sheldon.