Home > database >  How to link a Watson service to a folder in IBM Cloud, the way I can use it on AJAX JQuery?
How to link a Watson service to a folder in IBM Cloud, the way I can use it on AJAX JQuery?

Time:11-05

I have the following code in JQuery:

// Using the core $.ajax() method
$.ajax({
                 
    // The URL for the request
    url: "XXX",
                 
    headers:{
        'Content-Type': 'text/plain;charset=utf-8', 
        'Accept': 'application/json',
        'Authorization' : 'Basic '   btoa("apikey:" "XXX") //The API-KEY
    },

This code works on cloud IBM but the problem it's that the api-key it's visible for the client. Is there a way to link the url to a folder in my cloud server the way I can put in the url request, for example '/tone-analyzer' and without the api-key? Am I not in the intern side of my cloud? Why I can't directly call to Tone Analyzer service? Have I to configure some api gateway? Sorry I'm a bit new to the cloud concepts. Any help will be welcome.

CodePudding user response:

Before launching your product in production, you should use a back-end service to obscure your API key. Any API key in the browser can easily be inspected and re-used, running up your hosting bills.

More information: https://www.freecodecamp.org/news/private-api-keys/

  • Related