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/

Related Query

More Query from same tag