[英]Deploying reactJS application - routing issues in production mode
I've got some routing issues after deploying in production mode. 在生产模式下部署后,我遇到了一些路由问题。 (My app runs on an aws S3 Bucket) everything works fine only routing has some issues.
(我的应用程序在aws S3存储桶上运行),一切正常,只有路由出现问题。
Matching not known Routes are the Problem. 问题是匹配未知路由。 I have the following routing:
我有以下路由:
import {BrowserRouter as Router, hashHistory, Switch, NavLink, Route} from "react-router-dom";
<Provider store={store}>
<AppContainer>
<Router history={createHistory}>
<div>
<ThemeProvider theme={theme}>
<div className={i.content}>
{/*Switch is for Error Routing*/}
<Switch>
<Route exact path="/" component={() => (<Logins foo={"test"} loginHandler={this.props.loginHandler}/>)}/>
<Route path="/logout" component={() => (<Logins foo={"test"} loginHandler={this.loginHandler}/>)}/>
<Route path="/signup" component={() => (<SignUp loginHandler={this.loginHandler}/>)}/>
<Route path="/imprint" component={() => (<Impressum/>)}/>
<Route path="/verification/:verificationToken/:verificationEmail" component={() => (<Verification/>)}/>
<Route component={() => (<Error/>)}/>
</Switch>
<div className={i.footer}>
<a href="https://johner-institut.de" target="_blank">{t('application:made')} <img src={jilogo} width="8px;"/>
</a> | <NavLink to="/imprint">{t('application:imprint')}</NavLink> | <LanguageChooserSmall/>
</div>
</div>
</ThemeProvider>
</div>
</Router>
</AppContainer>
</Provider>
Known Routes working fine. 已知路线运行良好。 But in error case the Switch should affect all not known routes should be redirected to
<Route component={() => (<Error/>)} />
but that's not working ... 但是在错误的情况下,交换机应该影响所有未知路由,应该将其重定向到
<Route component={() => (<Error/>)} />
但这不起作用...
what could be the problem? 可能是什么问题呢?
尝试在cloudfront的custom error response
设置中将response page path
设置为index.html
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.