lahsivjar / react-stomp

React websocket component for STOMP protocol over SockJs
https://www.npmjs.com/package/react-stomp
MIT License
134 stars 41 forks source link

Unable to connect cause of "CORS error" #194

Open KtfwyCJ opened 3 years ago

KtfwyCJ commented 3 years ago

SocketJsClient:

<SockJsClient
        url="http://xxxx/ws"
        topic="/messages"
        onConnect={() => {
          console.log(111);
        }}
        onDisconnect={(err) => {
          console.log('err', err);
        }}
        onMessage={(msg) => {
          console.log(msg);
        }}
        ref={(client) => {
          console.log('client', client);
          setClientRef(client);
        }}
      />

Proxy config:

proxy: {
    "/ws/**": {
      "target": "http://xxxx",
      "changeOrigin": true
    }
  }