Last active
August 30, 2021 10:05
-
-
Save satnami/9b9f2ec06de5311b83f3216d7ec45a79 to your computer and use it in GitHub Desktop.
S3 routing with react routing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import ReactDOM from "react-dom"; | |
import { Provider } from "react-redux"; | |
import { createBrowserHistory } from "history"; | |
import configureStore from "./redux/configureStore"; | |
import * as serviceWorker from "./serviceWorker"; | |
import App from "./App"; | |
import ErrorBoundary from "./pages/ErrorBoundary"; | |
const store = configureStore(); | |
const history = createBrowserHistory(); | |
const root = document.getElementById("root"); | |
if (root) { | |
// 1. Set up the browser history with the updated location (minus the # sign) | |
const path = (/#!(\/.*)$/.exec(window.location.hash) || [])[1]; | |
if (path) { | |
history.replace(path); | |
} | |
// 2. Render our app | |
ReactDOM.render( | |
<ErrorBoundary> | |
<Provider store={store}> | |
<App /> | |
</Provider> | |
</ErrorBoundary>, | |
root, | |
); | |
} | |
// If you want your app to work offline and load faster, you can change | |
// unregister() to register() below. Note this comes with some pitfalls. | |
// Learn more about service workers: https://bit.ly/CRA-PWA | |
serviceWorker.unregister(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Static website hosting | |
# Redirection rules with React Routing | |
[ | |
{ | |
"Condition": { | |
"HttpErrorCodeReturnedEquals": "404" | |
}, | |
"Redirect": { | |
"HostName": "spa.satnami.xyz", | |
"ReplaceKeyPrefixWith": "#!/" | |
} | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment