我想使用 S3 + Cloudfront 在子文件夹中提供 2 个不同的 React 应用程序
myapp.com/app-one/<-- 这是index.html
myapp.com/app-two/<-- 这是另一个index.html
我知道如何配置 create-react-app 和 React router 来处理这个问题。
https://create-react-app.dev/docs/deployment/#building-for-relative-paths
问题在于配置 S3 + Cloudfront 来处理重定向。
当您在浏览器中输入 url 时:
myapp.com/app-one/some-route- 它应该重定向到index.html of app-one
myapp.com/app-two/some-route- 它应该重定向到index.html ofapp-two
不幸的是,S3 只允许您定义一个后备file.html( 404)Static website hosting
我也不想使用 hashrouter:https://github.com/ReactTraining/react-router/blob/master/packages/react-router-dom/docs/api/HashRouter.md
amazon-s3 amazon-cloudfront single-page-application reactjs react-router