Routing issue with single page react app embeded in a paged site

13 Views Asked by At

I have a react app that is embedded in a standard web page layout folder, I am using browser router to do the routing in the app, this works fine on local host, the react app is a webmodule monorepository setup and each project in the repository has its own index file and can run independently from each other, I have a host project that when run uses all the other exposed modules from the other projects, all works well on local. When I build it and put it onto AWS is where the issue starts, I have an S3 cloud front setup, so I have set the S3 bucket to be a single page app(even though the main app that the react app is in is a file served system) I have created a cloud front node.js script to detect the responses and requests and based on them, I set a 404 or 404 (actalually anything between 400 and 500) if I recall, if it is under the folder with the react branch it reverts to the index.html in that folder otherwise it goes to the root folder of the main site, we also catch if any of th files don't end in index.html and redirect to index if they don't, the problem is sometimes ot uses the individual projects index page and other times it uses the main root(of the reqct project) index page, apologies I am writing this on my phone on long train journey, any help would be appreciated, thanks in advance

0

There are 0 best solutions below