score:0
You need to map all paths to the index.html file. Because your project is SPA.
score:0
I have solved the problem this way.
First I have set AWS S3 redirection rules as such
[
{
"Condition": {
"HttpErrorCodeReturnedEquals": "404"
},
"Redirect": {
"ReplaceKeyWith": ""
}
}
]
In this way, any time a 404 error is raised, the redirect policy brings to the Index document (i.e. the empty key).
Moreover, to make sure that even if this configuration is not set, I have forced to navigate to the Home
component using an effect hook in the top level component, something like this
const history = useHistory();
useEffect(() => {
history.push("/");
}, [history]);
Source: stackoverflow.com
Related Query
- Redirect to home when React app served by S3 is called with url containing a route
- React app not loading js file when accessing it with a non home page url
- Can't redirect with a proxy to Node server when hosting a React app on AWS S3 bucket
- React app gets 404 when fetching url with params
- url redirected successfully, but component is not called when using redirect on react js typescript
- Mock function doesn't get called when inside 'if' statement - React app testing with jest and enzyme?
- Issue with babel-jest dependency when running npm start in a React app
- React component render is called multiple times when pushing new URL
- React-Router issues when serving React App with Spring Boot
- Where to store WebRTC streams when building React app with redux
- React Native app works when run from Xcode, but crashes when run with 'react-native run-ios'
- React app showing page with "404 the requested path could not be found" when using Apache
- React router: catch a login-success url with a token being passed then redirect to homepage
- Unicode characters not showed when bundling and deploying React app with webpack and babel
- React: Trying to rewrite ComponentDidUpdate(prevProps) with react hook useEffect, but it fires when the app starts
- How to properly initialize React app with redux in Cordova - mapStateToProps not called
- React JS App becomes blank white screen when deployed with AWS Amplify
- Is it Possible to redirect to installed flutter app page from react app when open in mobile browser
- Component not mounted when setState called in arrow function in React with ES2016
- App doesn't run when exporting react & react-router to a stand alone html file with webpack
- React JS Not Completely Updating View When Render Is Called With New Props
- React Router v6 redirect when there are not any url queryString parameters
- How do I hide the source code when deploying react app with firebase?
- How to avoid error 'Unexpected token <' with a React app when running babel from a CDN?
- Exclude index.html from express.static when serving React app with Express
- Advice when working with long running post requests from a React app to NodeJS Backend
- React Router with Meteor: How to remove code param from URL after redirect from OAuth without reload
- How to redirect react app to non www with htaccess file?
- 404 Not Found error in preflight OPTIONS when executing a PUT method in CakePHP API with axios in React App
- Create React App with react-svg-loader without ejecting fails when trying to minify
More Query from same tag
- How to get the properties of the unique values in array?
- How to use a react-router Link or history.push within a gridjs cell
- External CSS/JS in Gatsby
- How to edit a form in React and Redux?
- Send Email using nodemailer
- How to create a static website generator in React
- React.ForwardRef TypeScript Component Type Error
- What TypeScript type should I use to reference the match object in my props?
- Making React useEffect check whether video link has video available
- react-intl currency displayed without decimals
- React App doesn't make proxy calls after deployed to azure
- CSS not changing when using React Router to route to another component
- get clicked button's name
- React with NodeJS and Webpack - bundled js big file size
- react router v6 doesn't work if a question mark is attached to url
- Text input field won't submit when pressing enter
- Add mouse hover effects into style
- How to change the style of an element when clicked in React
- vertical divider not working in material ui
- How do I Link Components correctly using React Router?
- Yup and react-hook-form: how to create conditional mandatory fields in a form?
- Conditional react attributes
- React Too many re-renders
- How to add a permanent filter function to a List view in react-admin?
- Rendering JSON child list from object list in ReactJS
- Reactstrap Modal unmount on close
- How do I name my react component to accommodate an element in my nested JSON?
- How to interpolate two <a> tags with the Trans component that react-i18next provides?
- What is causing this JSON to have an unexpected EOF?
- React hooks not being set properly with JSON API response