在AWS Amplify上设置Express&Reaction的代理 [英] Setting up proxy for Express & React on AWS Amplify

查看:22
本文介绍了在AWS Amplify上设置Express&Reaction的代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

推荐答案

如果您要使用"常规rest API"(即非图形QL、无appsync),则最有可能配置带有lambda函数集成的api网关。

对于lambda,您可以配置"Serverless ExpressJS Function",并将您的快速代码放在lambda中。

举个例子:

$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映像)

这篇关于在AWS Amplify上设置Express&Reaction的代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆