amazon-web-services - 从客户端调用 API 时出现错误代码 500
问题描述
我有一个 Lambda 函数,当我从我的 React 应用程序调用它时,我收到以下 2 个错误:
POST https://x7429ccke5.execute-api.eu-west-1.amazonaws.com/prod/sites 500
和
Uncaught (in promise) Error: Request failed with status code 500
at createError (createError.js:17)
at settle (settle.js:19)
at XMLHttpRequest.handleLoad (xhr.js:78)
我的网站上还没有登录系统,所以我想在不需要许可的情况下调用 api,所以在我的 serverless.yml 上,我把它作为
functions:
# Defines an HTTP API endpoint that calls the main function in create.js
# - path: url path is /notes
# - method: POST request
# - cors: enabled CORS (Cross-Origin Resource Sharing) for browser cross
# domain api call
# - authorizer: authenticate using the AWS IAM role
createSite:
handler: CreateSite.main
events:
- http:
path: sites
method: post
cors: true
arn: "arn:aws:execute-api:eu-west-1:106845550704:x7429ccke5/*/POST/sites"
解决方案
我怀疑问题出在 API Gateway 与 lambda 的集成上。引发 500 错误的是您的 API 网关。请检查您的 API 网关是否已暂存。如果它已上演,请检查以下内容:
让我知道它是否仍然不起作用。
推荐阅读
- reactjs - 我如何在 redux-observable 中使用“of”
- python - OpenAI健身房cartpole-v0理解观察和动作关系
- r - 映射矩阵 R
- android - 为什么会出现此错误:在调用超类型构造函数之前无法引用“ViewHolder.itemView”
- android - 如何在 Android Studio 中对裁剪图像进行实时图像处理
- android - 无法修改 HERE Maps 重新路由路线选项
- android - Android - 如何在 RecyclerView 中更新自定义列表项单个组件?
- c++ - 如果我不关闭 ifstream 会导致内存泄漏吗?
- preg-match - 我想使用 preg_match() 函数添加阿拉伯字符
- plot - 如何创建分解数据到类别的图表?