簡體   English   中英

部署reactJS應用程序-生產模式下的路由問題

[英]Deploying reactJS application - routing issues in production mode

在生產模式下部署后,我遇到了一些路由問題。 (我的應用程序在aws S3存儲桶上運行),一切正常,只有路由出現問題。

問題是匹配未知路由。 我有以下路由:

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>

已知路線運行良好。 但是在錯誤的情況下,交換機應該影響所有未知路由,應該將其重定向到<Route component={() => (<Error/>)} />但這不起作用...

可能是什么問題呢?

嘗試在cloudfront的custom error response設置中將response page path設置為index.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM