Found this in the `N/https` page: ``` // Request t...
# suitescript
e
Found this in the
N/https
page:
Copy code
// Request to an existing suitelet with credentials
            var passwordGuid = option.request.parameters.password;
//Replace SCRIPTID and DEPLOYMENTID with the internal ID of the suitelet script and deployment in your account 
            var baseUrl = url.resolveScript({scriptID:SCRIPTID,deploymentId:DEPLOYMENTID,returnExternalURL:true});
            var authUrl = baseUrl + '&pwd={' + passwordGuid + '}';
            var secureStringUrl = https.createSecureString({
               input: authUrl
            });
            var secureStringPWD = https.createSecureString({
               input: '{' + passwordGuid + '}'
            });
            var headers = {
               'pwd': secureStringPWD
            };
            var response = https.get({
               credentials: [passwordGuid],
               url: secureStringUrl,
               headers: headers
            });
z
Did this work? I was going to suggest figuring out how to do the equivalent of xhr.withCredentials = true
because i’ve made successful requests to suitelets from external sites that way
e
I haven't implemented it yet
a
@zach_calh Would you mind to share an example?
z
Copy code
var xhr = new XMLHttpRequest();
      
        xhr.open("POST", requestUrl, true);
        xhr.onload = function() {
          if(xhr.readyState === 4 && xhr.status === 200) {
            return resolve(xhr.responseText)
          } else {
            return reject(xhr.responseText);
          }
        }
      
        xhr.withCredentials = true;
        xhr.responseType = "text";
        xhr.send(JSON.stringify(body));
👍 1
This allows you to hit the endpoint successfully
But unless you set the headers successfully on the http.response object, you’ll get a CORS error for the response