Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs Api CORS不允许凭据_Reactjs_Api_React Chat Engine - Fatal编程技术网

Reactjs Api CORS不允许凭据

Reactjs Api CORS不允许凭据,reactjs,api,react-chat-engine,Reactjs,Api,React Chat Engine,我试图在我的网站上实现聊天引擎,但在尝试访问聊天引擎api时,我得到--CORS不允许凭据--“如果CORS标头“access Control Allow Origin”为“*”,则不支持凭据。” chat.js import { ChatEngine } from 'react-chat-engine'; import React from 'react'; import LoginForm from './components/LoginForm.jsx' import './chat.c

我试图在我的网站上实现聊天引擎,但在尝试访问聊天引擎api时,我得到--CORS不允许凭据--“如果CORS标头“access Control Allow Origin”为“*”,则不支持凭据。”

chat.js

import { ChatEngine } from 'react-chat-engine';
import React from 'react';

import LoginForm from './components/LoginForm.jsx'
import './chat.css';

const projectID = 'projectID ';

const chat = () => {
  if (!localStorage.getItem('username')) return <LoginForm />;

  return (
    <ChatEngine
      height="100vh"
      projectID={projectID}
      userName={localStorage.getItem('username')}
      userSecret={localStorage.getItem('password')}
    />
  );
};

export default chat;
从'react chat engine'导入{ChatEngine};
从“React”导入React;
从“./components/LoginForm.jsx”导入LoginForm
导入“./chat.css”;
常量projectID='projectID';
const chat=()=>{
如果(!localStorage.getItem('username')返回;
返回(
);
};
导出默认聊天;
起初,我甚至无法登录,并且遇到了相同的错误,但我通过在axios.post中添加
withCredentials:false
来修复它