gpt4 book ai didi

Javascript React 单页应用程序 + Amazon S3 : Permalinks issue

转载 作者:行者123 更新时间:2023-11-29 19:19:17 24 4
gpt4 key购买 nike

我使用 S3 存储桶作为静态 Web 解决方案来托管单页 React 应用程序。当我点击根域 s3-bucket.amazon.com 时,React 应用程序工作正常并且每次我单击链接时 HTML5 历史记录 api 工作正常,新 url 看起来很好:_http://s3 -bucket.amazon.com/entities/entity_id_当我使用永久链接访问应用程序时会出现问题。假设我在浏览器中输入相同的 url (_http://s3-bucket.amazon.com/entities/entity_id_) 我将从 Amazon S3 收到以下错误:

404 Not Found
Code: NoSuchKey
Message: The specified key does not exist.
Key: users
RequestId: 3A4B65F49D07B42C
HostId: j2KCK4tvw9DVQzOHaViZPwT7+piVFfVT3lRs2pr2knhdKag7mROEfqPRLUHGeD/TZoFJBI4/maA=

是否可以使 Amazon S3 与永久链接和 HTML5 历史记录 api 很好地协同工作?也许它可以充当代理?

谢谢

最佳答案

使用 AWS CloudFront 的解决方案:

第 1 步:转到 CloudFront

点击分布id

转到错误页面选项卡

点击创建自定义错误响应

第 2 步:将表格填写为

HTTP 错误代码:404

TTL:0

自定义错误响应:是

响应页面路径:/index.html

HTTP 响应代码:200

来源:https://medium.com/@nikhilkapoor17/deployment-of-spa-without-location-strategy-61a190a11dfc

关于Javascript React 单页应用程序 + Amazon S3 : Permalinks issue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33723778/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com