For general context I'm working on an app that uses Roda as an API server, primarily as companion to an Electron desktop app.
Additionally, Roda is also serving a small frontend app built with React for account management/authentication that sends requests to Rodauth paths. The React app is mounted in Roda as such:
route do |r|
r.public
r.root do
File.read("public/index.html")
end
end
I defined a few routes in the frontend using
React Router which work fine as long as you navigate to them from the root path.
The issue I have is that after I navigate to one of these routes (i.e. "/sign-up") and then I refresh the page that next request is handled by Roda and I get a 404 since that path isn't defined in the backend.
If I "duplicate" the routes in Roda to match those in React Router and point them to the same static file I can get the behavior to work as expected:
r.root do
File.read("public/index.html")
end
r.get "sign-up" do
File.read("public/index.html")
end
What I wonder if there is a more efficient/cleaner way of handling this situation?
I'm new to Roda, so any insight you can offer will be highly appreciated.
Thanks!