I'm a php/js developer and have no knowledge of c# /asp, trying to talk to signalR API for the first time I found this package
https://github.com/SignalR/bower-signalr
which seems to allow me to talk to signalR API using javascript client
here is my code
<!DOCTYPE html>
<html xmlns="">
<head>
<script src="bower-signalr-master/jquery-1.6.4.min.js" type="text/javascript"></script>
<script src="bower-signalr-master/jquery.signalR.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
var connection = $.connection('https://firouzex.exphoenixtrade.com/realtime');
connection.logging = true;
connection.start({ transport: "webSockets" });
});
</script>
</head>
<body>
</body>
</html>
when i run it i get this error
(index):1 Access to XMLHttpRequest at 'https://firouzex.exphoenixtrade.com/realtime/negotiate?clientProtocol=2.0&=1560606196092' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. jquery-1.6.4.min.js:4 Cross-Origin Read Blocking (CORB) blocked cross-origin response https://firouzex.exphoenixtrade.com/realtime/negotiate?clientProtocol=2.0&=1560606196092 with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details. send @ jquery-1.6.4.min.js:4 ajax @ jquery-1.6.4.min.js:4 ajax @ jquery.signalR.js:1248 negotiate @ jquery.signalR.js:715 (anonymous) @ jquery.signalR.js:833 start @ jquery.signalR.js:834 connection._.deferredStartHandler @ jquery.signalR.js:532 handle @ jquery-1.6.4.min.js:3 k @ jquery-1.6.4.min.js:2 load (async) add @ jquery-1.6.4.min.js:2 f.fn. @ jquery-1.6.4.min.js:3 f.fn. @ jquery-1.6.4.min.js:3 load @ jquery-1.6.4.min.js:4 (anonymous) @ jquery.signalR.js:261 (anonymous) @ jquery.signalR.js:1068
I've searched around about this error, but all the solutions seems to be have something to do with c# code
I also tried
connection.start({ transport: "webSockets", jsonp: true });
this one gives me
net::ERR_ABORTED 403 (Forbidden: JSONP is disabled.)
from javascript signalR client : CORS policy error trying to connect to api
No comments:
Post a Comment