This should work well for your App when the user tries to access a Client side route and refresh the page or when trying to access the route later. Your app is ready to be deployed See the section about deployment for more information. The build is minified and the filenames include the hashes. It correctly bundles React in production mode and optimizes the build for the best performance. Then create a web.config file for your App or create a new one with code as shown below: Builds the app for production to the build folder. 1 import React from react 2 import ReactDOM from react-dom 3. Add the following code block to your index.js file. 1 npx create-react-app YOURAPPNAME & yarn add react-router-dom. To solve this, send all your requests back to IIS with URL rewrite to the index.html static file and let the React App handle the routing.įirst install the URL Rewrite module on the IIS Server. Setup a React app by entering the following command or entering react.new in your browser to set up a React development environment on codesandox.io. Since your React App is a Single Page Application (SPA), the Server is unaware of any static files like courses and will give 404 error. This problem is not known while debugging the App in localhost until you host the App on an IIS Server. When trying to handle Client side routing for your React App hosted on IIS say using react-router-dom, you might need to handle situations where users access specific sections of your App like Users might even save these URLs in their favorites and try to access them later.
0 Comments
Leave a Reply. |