Sharepoint CORS Policy issue persist even after ISS Configurations

Copper Contributor

I am currently trying to fetch my Sharepoint API via my code. However I am running into the issue below. I have already enabled the ISS Configurations as shown in the link below. However, the issue still persist.


  index.html:1 Access to XMLHttpRequest at 'http://testing-   sharepoint/Shared%20Documents/query%20result%20BEFORE.xml' from origin ''    has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

My code:

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src=""></script>

        $(document).ready(function() {
            function apiCallTest(searchValue) {
                const adminAccount = 'testUser';
                const adminAccountPassword = 'testPassword';

                const auth = btoa(`${adminAccount}:${adminAccountPassword}`);

                const testQuery = 'BEFORE';

                const apiUrl= "http://testing-sharepoint/Shared%20Documents/query%20result%20BEFORE.xml"

                const headers = {
                    'Authorization': `Basic ${auth}`,
                    // 'Accept': 'application/json;odata=nometadata',
                    // 'Content-Type':'application/json',
                    // 'Access-Control-Allow-Credentials':'TRUE',
                    // 'Access-Control-Allow-Headers':'Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers,Authorization',
                    // 'Access-Control-Allow-Origin':'*',
                    // 'Access-Control-Allow-Methods':'GET,POST,PUT,OPTIONS'

                    url: apiUrl,
                    headers: headers,
                    method: 'GET',
                    dataType: 'xml',
                    success: function(data) {
                        // Process the search results as needed
                        console.log('Search Results:', data)
                    error: function(xhr, textStatus, errorThrown) {
                        console.log("Cannot connect")
                        console.error('Error:', xhr, textStatus, errorThrown);
            function checkConnection(url) {
                if (navigator.onLine) {
                    console.log(`You are online. Checking connection to ${url}...`);
                    // You can attempt further actions here if needed
                } else {
                    console.log('You are offline. Check your network connection.');


<body style="background: black; color: aliceblue; font-size: 2rem;">

0 Replies