Open Closed

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


User avatar
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)
  • User Avatar
    0
    alper created
    Support Team Director

    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.

  • User Avatar
    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.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11