Search code examples
javascriptreactjscreate-react-app

Redirect to sub page


I have gitpage with structure:

pages\

------other-page-a\

-------------------index.html

------other-page-b\

-------------------index.html

------other-page-c\

------------------- ...

static\

asset-manifest.json\

favicon.ico\

index.html\

manifest.json\

service-worker.js\

Main page is react app but some pages in "pages" folder not.

I try to redirect using

   <div
              className="button"
              onClick={() =>
                (window.location.replace = https://stepanvanzuriak.github.io/pages/newspaper
                )
              }
            >

But this not work, link changes but page not

SOLUTION: Make eject and remove navigateFallback in SWPrecacheWebpackPlugin


Solution

  • It seems that you are trying to reach a document thats not exposed from the node-server. Since the server is probably setup with a fallback (returning the same index.html no matter what url you put in). Every request will then return the main-index with the react-app in it. Adding the other folders as static folders to be exposed in the node server should do the trick