【发布时间】:2017-07-02 11:05:07
【问题描述】:
我正在使用从 https://github.com/facebookincubator/create-react-app 创建的 ReactJS SPA
我正在使用 S3 和 Cloudfront 为我的网站提供服务。在我重新加载页面之前一切正常 - 它会引发错误(在我的情况下访问被拒绝),因为它无法在没有 Hashbang 的情况下处理。
注意:如果我输入带有 hashbang 的 URL 就可以了
所以本质上,这行得通:https://example.com/#/dashboard(重定向到https://example.com/dashboard)
但是如果我刷新页面,它会给出如下错误:
我们使用 browserHistory 来维护路线。我只显示相关代码:
<Router history={browserHistory}>
<Route path='/dashboard' component={Dashboardpage} />
</Router>
【问题讨论】:
标签: reactjs amazon-s3 amazon-cloudfront hashbang create-react-app