having CORS issue during chat API



2022년 7월 05일에 게시됨

Hello Team, 

I am using streaming API for live chat.

Streaming API:http:// https://developer.zendesk.com/api-reference/live-chat/real-time-chat-api/streaming/ 

Here is the code:

 
 var WebSocket = require('ws');
       var ws_client = new WebSocket(
         'wss://rtm.zopim.com/stream', {
           headers: {
             'Authorization': 'Bearer  {Auto_token}' ,
             'Access-Control-Allow-Origin': '*' ,
             'Access-Control-Allow-Headers': 'Origin, Content-Type, X-Auth-Token',
             'Access-Control-Allow-Credentials': 'true'
           }
         }
       );

 

Having below error in console:

Access to fetch at 'https://rtm.zopim.com/stream' from origin 'http://localhost:4567' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.

 

does anybody have an idea to resolve this?

Thanks,

Charmi


0

1

댓글 1개

Hi, 
 We looked a bit further into the problem and it seems Access-Control-* headers were been added that's causing the failure. Is there any specific reason for adding these headers given our API documentation has no mention of these headers? 

var WebSocket = require('ws');
       var ws_client = new WebSocket(
         'wss://rtm.zopim.com/stream', {
           headers: {
             'Authorization': 'Bearer  {Auto_token}' ,
             'Access-Control-Allow-Origin': '*' ,
             'Access-Control-Allow-Headers': 'Origin, Content-Type, X-Auth-Token',
             'Access-Control-Allow-Credentials': 'true'
           }
         }
       );

0


댓글을 남기려면 로그인하세요.

원하는 정보를 못 찾으셨나요?

새 게시물