1

I'm trying to build a new frontend on top of an existing GAE application using React, Redux and Redux-Router. My problem is figuring out how to make GAE always fallback to the html page where Redux-Router will take care of the routing.

Right now, if I go to '/' the app works fine and the navigation is perfect. When I refresh the page GAE kicks in and tries to find the route.

How do I configure GAE to always go the same html? oh, only if the url doesn't start with api/ to serve my data?

Thanks for the help

2 Answers2

1

web.xml (under 2.5) allows you to wildcard the start or the end of the path (but not anywhere in the middle)

You should achieve what you're after by using /* - which is basically any path not mapped by another rule. Your /api/*rule should continue to work.

Nick
  • 1,822
  • 10
  • 9
  • For some reason it works fine locally but when deployed to GAE it fails with a strange error: java.lang.IllegalStateException: No forced path servlet for /index.html – sleeveroller Feb 07 '17 at 08:30
  • Are you trying to load index.html in the browser? You can map that as a static resource in appengine-web.xml – Nick Feb 07 '17 at 08:32
  • I'm already serving it from static resources...changing it to JSP file and setting 404 to fallback to the main jsp seems to solve it! – sleeveroller Feb 10 '17 at 13:01
0

Assuming you're using Python in the backend the following would do the trick in your main.py - where IndexHandler is the handler you use to render the "html page where Redux-Router will take care of the routing".

app = webapp2.WSGIApplication([
    ('/.*', IndexHandler)],
    config=config,
    debug=DEBUG)
Aaron
  • 801
  • 1
  • 7
  • 12