【发布时间】:2021-06-22 01:45:39
【问题描述】:
我已经发布了我的 React 应用程序以进行放大,那里一切正常。但是,当我打开放大 URL 时,我看到没有从数据库中获取任何项目,并且控制台中出现错误提示“无凭据”
我认为问题出在 AppSync API 上。 我使用 Amplify CLI 制作的,它使用 API 密钥身份验证。
我在本地使用生成的文件aws-exports.js 提供凭据。我像这样在我的index.tsx 中导入这个:
import awsmobile from "./aws-exports";
Amplify.configure(awsmobile);
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);
但是这个文件没有被推送到 git,所以 Amplify 显然没有这个来自 repo。但我假设它能够生成自己的aws-exports.js 文件,因为它不会在导入时出现任何错误。
那么,我在这里缺少什么?我是否必须在我的 AppSync api 上使用其他方法进行身份验证,或者这里有什么问题? 谢谢!
【问题讨论】:
标签: reactjs amazon-web-services aws-amplify aws-appsync