0

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.

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 ...

what could be the problem?

8
  • d'you get any errors or anything? 'not working' is not very descriptive.. Commented Aug 11, 2017 at 9:21
  • It returns a 404 not found Commented Aug 11, 2017 at 9:23
  • and the 404 is coming from the server? Commented Aug 11, 2017 at 9:27
  • yes from the S3 bucket Commented Aug 11, 2017 at 9:28
  • 1
    have you tried setting response page path to index.html in clodfronts custom error response setting? Commented Aug 11, 2017 at 9:32

1 Answer 1

1

Try setting the response page path to index.html in the custom error response setting in cloudfront.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.