我正在尝试在我的React应用程序中实现SharePoint文件浏览器。使用microsoft/file-browser
进行此操作,代码如下。但是出现了xxx... from origin 'http://localhost:3000' has been blocked by CORS policy
的错误。
有什么想法可以启用CORS吗?
import * as React from "react";
import { GraphFileBrowser } from '@microsoft/file-browser';
class App extends React.Component {
getAuthenticationToken() {
return new Promise<string>(resolve => {
resolve(
"VALID TOKEN"
);
});
}
render() {
return (
<GraphFileBrowser
getAuthenticationToken={this.getAuthenticationToken}
onSuccess={(selectedKeys: any[]) => console.log(selectedKeys)}
onCancel={(err: Error) => console.log(err.message)}
endpoint='https://XXX.sharepoint.com'
/>
);
}
}
export default App;