score:1
Accepted answer
as per the previous person, you need to add this after your app.use routes part in your server-dev.js
app.get('*', (req, res) => {
res.sendfile(path.join(__dirname + '/index.html'));
})
this should fix it
score:0
you can try with this sample of code (in case you are using the server for serving only the react app):
app.get('*', (req,res) =>{
res.sendfile(path.join(__dirname+'/client/build/index.html'));
});
where you can replace the link of the index.html file as per your file structure.
Source: stackoverflow.com
Related Query
- After building react app using webpack, browserRouter does not allow me to go directly to a route, but hashRouter does?
- React Routes not working after building the app using webpack
- React router not working after building the app
- React Testing Library does not find elements using getAllByTestId after initial render
- How to create React App including Web3 using create-react-app? I am getting Module not found Error. BREAKING CHANGE: webpack < 5 used
- window.location does not work with react app using react router 4
- Is there a way to load react library files separately and not in the bundled files when using react with babel, webpack and gulp as building tool?
- React tests are not working after building it by Webpack
- My react app not running in IE11 after migrated Webpack from v4 to v5
- Why does my React app menu open when I am only changing the state and am not using any CSS?
- How does Create React App allow for Array.prototype.at() while it's not allowed by TypeScript?
- Styles not inserted into HEAD using Webpack MiniCssExtractPlugin with Create React App
- Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema
- google is not defined in react app using create-react-app
- Webpack 4 and react loadable does not seems to create correct chunk for server side rendering
- React Context api - Consumer Does Not re-render after context changed
- Why does production build of React app (with Webpack and Babel) use wrong development env with HMR, which causes errors?
- React native buttons OnPress does not fire when app running in debug mode
- State using React Typescript: Property does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes
- React does not rerender after setState used in promise
- React does not refresh after an update on the state (an array of objects)
- Load third party iframe in React after page load, so that the iframe does not affect PageSpeed score
- docker-compose stops immediately after starting react app created using create-react-app
- react component state change after ajax call but does not rerender component
- JSDoc does not work in local package in a Lerna monorepo project using webpack dev server but works when released to package registry
- Typescript does not error on compilation with create react app
- Does a React Native app need read/write permission on Android if using asyncstorage?
- does not contain a default export even after being correctly imported in React
- Webpack error: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema
- Webpack: npm start "Module not found: Error: Can't resolve ..." after moving location for webpack / react files
More Query from same tag
- Confusion with default import of React
- React component retrieves props just once, goes undefined when refreshed
- quilljs replace <strong> with <b>
- Attached form button doesn't trigger form submit when clicked
- why is my firebase authentication display name not getting updated properly with react js?
- Using redux-form fieldInputPropTypes throwing error in console
- adding react routes to router in react produces blank page
- Algolia - How to customize the tags display name in the menuSelect dropdown list
- How can I properly use USParser() to get my computers CPU in ReactJS?
- webpack failing to compile in a react app
- How to redirect to parent route if page doesn't exist?
- How to call a NodeJs resource from React Js
- redux devtools chrome extensions - No store found
- Extending React components in TypeScript
- Receiving image file in paste/drop event in React
- how can I put a document.addEventListener("scroll") in other file to call it in my component?
- React: Pass function to child component as props, call onClick in child component
- I am not able to install create react app on my m1 macbook pro
- How can I join one column in other table with Laravel?
- Change react antd DatePicker language
- React add class to one element from list after clicking on button
- Custom React Hook Causing Memory Leak Error
- How do you get the cursor position in a react TINYMCE
- React-Grid-Layout: How to re-render items on resize
- How to list all suggestions and filtered suggestions based on user input using reactjs?
- Mapping over an array and returning API result
- How can i move a text right of the screen and back to left of screen
- DJANGO + REACT + WEBPACK-DEV-SERVER
- How can I pass arguments in action different 3 level react components without redux and context API?
- CSS isn't loading on my react github pages deployment