1

I trying to make connection to server in React project but getting CORS error. What is the possible solution to this problem?

import { hubConnection } from 'signalr-no-jquery';
const connection = hubConnection('ip address');
const hubProxy = connection.createHubProxy('hubNameString');

connection.start({ jsonp: true })
.done(function(){ console.log('Now connected, connection ID=' + connection.id); })
.fail(function(){ console.log('Could not connect'); });

Console message:

Access to XMLHttpRequest at 'http://xxx' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Telirw
  • 373
  • 3
  • 15
  • Does this answer your question? [Why does my JavaScript code receive a "No 'Access-Control-Allow-Origin' header is present on the requested resource" error, while Postman does not?](https://stackoverflow.com/questions/20035101/why-does-my-javascript-code-receive-a-no-access-control-allow-origin-header-i) – ecarrizo Jul 21 '22 at 07:06
  • Did you configure CORS in your server-side application? – ggeorge Jul 21 '22 at 19:49

0 Answers0