简体   繁体   English

在 AWS BeanStalk 中使用 Spring 启动 REST API 部署 React 应用程序

[英]Deploying React App with Spring Boot REST API in AWS BeanStalk

I'm trying to deploy 2 instances (front and back end) separately.我正在尝试分别部署 2 个实例(前端和后端)。 Currently, the back end which is the REST API using SpringBoot was successfully deployed in BeanStalk as a.jar file.目前,使用 SpringBoot 的后端 REST API 已成功部署在 BeanStalk 中,为 .jar 文件。 Now, I have never deploy a front end app (in my case my React app) separately in AWS BeanStalk and I have been doing my research but I'm stuck.现在,我从未在 AWS BeanStalk 中单独部署前端应用程序(在我的情况下是我的 React 应用程序),我一直在做我的研究,但我被困住了。 How do I "compile" my React app and deploy it in BeanStalk like I did with the back end?我如何像在后端一样“编译”我的 React 应用程序并将其部署在 BeanStalk 中?

I got it, for anyone in the future needs help with this, all you have to do just follow these steps:我明白了,对于将来需要帮助的任何人,您只需按照以下步骤操作即可:

  1. Create a bucket and allow complete public access创建存储桶并允许完全公开访问
  2. Go to permission -> bucket policy -> add this script Go 到权限 -> 存储桶策略 -> 添加此脚本
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::(name-of-your-bucket)/*"
        }
    ]
} 
  1. add this to your package.json under scripts将此添加到脚本下的 package.json

"deploy": "aws s3 cp --recursive./build s3://(your-bucket-name)",

  1. execute npm run build in terminal在终端中执行npm 运行构建

  2. execute aws s3 cp --recursive./build s3://(your-bucket-name) in terminal (you are uploading your build files inside the build folder to s3) aws s3 cp --recursive./build s3://(your-bucket-name) in terminal (您正在将构建文件夹中的构建文件上传到 s3)

  3. go to properties -> static web hosting -> point out the index.html if you use that -> click the end point go 到属性 -> static web 托管 -> 指出您使用的索引。ZFC35FDC70D5227D256988

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 HTTP 使用 Spring 启动 REST ZDB974238714CA8DED63AZA 后端部署 React 前端时出现错误 405 - HTTP ERROR 405 when deploying React frontend with Spring boot REST API backend 使用Spring Boot API REST反应JS - React JS with Spring boot API REST 将React App部署到AWS - Deploying a React App to AWS 基于 React 的应用程序与 spring 启动捆绑在一起作为部署在 websphere 中的 WAR - React Based app with spring boot bundled together as a WAR deploying in websphere 将 asp.net Core REACT 应用程序部署到 AWS Beanstalk 时出现 IdentityServer 错误 - Error with IdentityServer when deploying asp.net Core REACT app to AWS Beanstalk 如何使用frontend-maven-plugin将来自React应用程序的REST api调用捆绑到Spring Boot中? - How to make REST api call from React app bundled into Spring boot using frontend-maven-plugin? 从 Spring 引导 REST API 重定向到分离的反应前端 - Redirect from Spring boot REST API to separated react frontend Spring 启动和 React js Paypal Rest api 支付网关 - Spring boot and React js Paypal Rest api payment gateway React 应用程序具有暂存环境并在 AWS Elastic BeanStalk 上使用 Docker 进行部署 - React Application to have a staging environment and deploying with Docker on AWS Elastic BeanStalk AWS Beanstalk CLI继续部署react / npm开发构建 - AWS Beanstalk CLI keeps deploying react/npm development build
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM