Reactjs Api CORS不允许凭据
我试图在我的网站上实现聊天引擎,但在尝试访问聊天引擎api时,我得到--CORS不允许凭据--“如果CORS标头“access Control Allow Origin”为“*”,则不支持凭据。” chat.jsReactjs 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
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
来修复它