-1

Server URL

http://3.17.60.171

Ajax call in client side

<script>
    
        "use strict";
        $(document).ready( function() {
             $.ajax({
        url: 'http://3.17.60.171/',
        success: function(data){
                console.log(data);
            },
            error: function(error){
                console.log(error.name +": " +error.message);
                }
        });
        });
    </script>

Is there any possibility to get the data without making any changes in the server side? The server side coding is written in python. I am unable to find the server source code.

I am getting this error eventually


Access to XMLHttpRequest at 'http://3.17.60.171/' from origin 'file://' 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.
3.17.60.171/:1 Failed to load resource: net::ERR_FAILED


Pent Terry
  • 101
  • 9
  • There are browser plugins that allow you to bypass CORS. Chrome example [plugin](https://chrome.google.com/webstore/detail/allow-cors-access-control/lhobafahddgcelffkeicbaginigeejlf). There is also a Firefox plugin. – MkMan Aug 26 '20 at 01:43
  • Thanks for the info, I tried added the extension before coming to this portal. But it didn't worked for me. – Pent Terry Aug 26 '20 at 01:50
  • Despite the fact that there **may** be plugins that bypass CORS restrictions, than actual answer is **no**. It's a security restriction and the server must send the proper headers in order for a browser to accept it. – gforce301 Aug 26 '20 at 01:51
  • if you do the request from another place different from browser it would work like express server. – Sheldon Oliveira Aug 26 '20 at 01:54

1 Answers1

0

The only successfully solution I've found to this is a proxy server. CORS is a browser security policy, so servers aren't mandated to follow it. So you could do

Browser -> CORS Enabled Proxy Server -> CORS Disabled Resource Server

https://cors-anywhere.herokuapp.com/ is an example of a free proxy server, but it is not intended for production use. It should be fine for personal projects though.

AdamExchange
  • 1,253
  • 1
  • 8
  • 16