首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在AWS Amplify上设置Express & React的代理

在AWS Amplify上设置Express & React的代理
EN

Stack Overflow用户
提问于 2020-05-25 13:46:30
回答 1查看 1.1K关注 0票数 1

我正在为我的一个项目使用AWS Amplify。我有反应在前面和快递作为后端。在我的本地主机中,我可以只向我的package.json添加一个代理并调用api,但是我如何在AWS中做到这一点呢?如何同时运行express和React并调用amplify中的api,或者我需要使用EC2吗?谢谢

EN

回答 1

Stack Overflow用户

发布于 2020-05-25 20:09:00

如果你想使用“常规REST api”(即非graphql,没有appsync),你很可能会配置一个带有Lambda函数集成的API Gateway。

对于lambda,您可以配置“无服务器ExpressJS函数”,并将您的快速代码放在lambda中。

下面是一个示例:

代码语言:javascript
运行
复制
$amplify add api
Scanning for plugins...
Plugin scan successful
? Please select from one of the below mentioned services: REST
? Provide a friendly name for your resource to be used as a label for this category in the project: myapi
? Provide a path (e.g., /book/{isbn}): /items
? Choose a Lambda source Create a new Lambda function
? Provide a friendly name for your resource to be used as a label for this category in the project: mylambda
? Provide the AWS Lambda function name: mylambda
? Choose the function runtime that you want to use: NodeJS
? Choose the function template that you want to use:
  CRUD function for DynamoDB (Integration with API Gateway)
  Hello World
  Lambda trigger
❯ Serverless ExpressJS function (Integration with API Gateway)

用于本地开发的本地lambda调用也是可能的(通常通过lambda docker镜像)

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61996486

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档