score:0
i finally figured it out. thanks, sebastián sethson for your answer, which lead to the right path.
i updated my routing to
<hashrouter basename="/">
<switch>
<route exact path="/" component={signup} />
<route path="/some" component={some} />
</switch>
</hashrouter>
score:1
i dont believe that work this:
<hashrouter>
<router>
<switch>
</switch>
</router>
</hashrouter>
i think that you need build the application, and run this. i see an common error:
react-scripts start
/bin/sh: 1: react-scripts: not found
i hope help you!
score:5
when serving the build/
output as a static site, you have to configure your nginx to always serve index.html
(otherwise, it will attempt to match the url path to a static folder/file, which doesn't exist). more info on this behavior can be found in the create-react-app
docs
if you're using the nginx docker image to serve your site, you need to set the following default.conf
:
server {
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
location ~ ^/$ {
rewrite ^.*$ /index.html last;
}
listen 80;
server_name localhost;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
note the rewrite ^.*$ /index.html
part that modifies any incoming call and serves index.html
.
your minimal dockerfile
would then look like this:
from nginx
copy default.conf /etc/nginx/conf.d/default.conf
copy build/ /usr/share/nginx/html/
Source: stackoverflow.com
Related Query
- Create react app breaks after deployment on refresh 404 with Nginx
- Create react app served with nginx and oauth gives me refresh page issue
- 404 Error on refresh with SPA React Router app in GitHub Pages
- react-router throwing 404 upon page refresh with React app hosted on GoDaddy
- Getting 404 with react router app with nginx
- Keeping user logged in after refresh/using refresh token with Google OAuth2 in React app
- nextjs axios requests inside getServerSideProps always return 404 after deployment with nginx
- serve react create app and Nodejs app with reverse proxy Nginx
- CORs error AFTER deploying React App and separate Node API to production Unbuntu server where React static files are servered with NGINX
- React app crashed with Heroku after deployment
- React Router refresh 404 with Nginx
- Blank page after deployment - React app with node
- 404 Not Found Nginx Error on Deployment of React App Build
- Create React App not showing error message with ErrorBoundary
- React app has to clear browser cache after new deployment
- React production router 404 after deep refresh firebase
- Create React App Dependency Issue with Webpack
- Cannot create a React app with create-react-app
- What's the easiest way to use Create React App with Relay?
- CSS styles disappear after refresh in React app
- create react app Configuration file after build app
- Has anyone been able to setup create react app with semantic-ui?
- How to read console.log from a mounted component with Enzyme and Jest in Create React App
- How do I configure my Nginx server to work with a React app in a subfolder?
- how to use .env.qa or .env.staging with create react app
- Create React app with React-Snapshot Pre-Rendering static files
- The React App works during `npm start` but returns 404 after build
- Nginx and Create React App (with React Router) full routes not working
- React App returns error after refresh
- Typescript does not error on compilation with create react app
More Query from same tag
- How to write a jest unit-test using the gatsby.navigate function?
- Pass Optional Event Handler to Custom Button
- aws amplify auth custom signup can not map undefined
- NGINX Reverse Proxy with multiple locations for multiple containers
- TypeError: readonly assignment error with React application in Safari
- Relay Modern fragment error (expect object to contain data....)
- Display elements from JavaScript object with Object.entries
- where am i going wrong in my nextPerson function,as the code is breaking once all the persons are lopped over
- Trying to perform an onLoad to render some information but nothing happens
- How to solve react-table error:- TypeError: plugin is not a function
- Execute Vanilla JS Scripts in React after DOM Render
- NextJS redirects not redirecting urls after define in next.config.js file
- React limit api results and view more items
- setState in useEffect not working in conjunction with localStorage
- How to turn this Component Class into a pure function Stateless Component (Typescript + React)
- How to handle asynchronous call in redux react application
- React & SCSS: SassError: Undefined variable
- Why socket.io does not work further on react components after I remove all listeners in another component?
- Calling a seperate function from within useEffect in react
- What is best approach to set data to component from API in React JS
- Getting a "Type is not assignable to type FunctionComponent<Props>" and "Type is missing the following properties from type 'React Element<any, any>'
- TableHeader of Material UI does not make the content bold
- React - How to use hook useState props to create a map function
- react-select: How do I resolve “Warning: Prop `id` did not match”
- Ternary operator inside render is not behaving correctly -react
- React.js useState function passed as a parameter doesn't rerender its component
- How can I validate a token?
- How to access dom element that is not inside JSX in React?
- Testing with Jest failed with Error: Error watching file for changes: EMFILE
- TypeError: Cannot destructure property 'position' of 'undefined' as it is undefined