Thursday, 20 June 2019

javascript signalR client : CORS policy error trying to connect to api

I'm a php/js developer and have no knowledge of c# /asp, trying to talk to signalR API for the first time

i tried using this client library from official signalR page

https://github.com/SignalR/SignalR/wiki/SignalR-JS-Client

here is my code

<script src="jquery.js" type="text/javascript"></script>
<script src="jquery.signalr-2.2.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {

        $.connection('https://firouzex.exphoenixtrade.com/realtime').start()
            .done(function(){
                 console.log('connection done!')
            })
            .fail(function(){
                console.log('error!');
            });


     });
</script>

but i got

Access to XMLHttpRequest at 'https://firouzex.exphoenixtrade.com/realtime/negotiate?clientProtocol=1.5&_=1560862133617' from origin 'http://localhost' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource



from javascript signalR client : CORS policy error trying to connect to api

No comments:

Post a Comment