Search code examples
htmlangularjssingle-page-applicationgoogle-cloud-storagepushstate

Website Configuration on Google Cloud Storage without error pages


I have a single page application that I am (trying) to host on Google Cloud Storage.

The application is at index.html, and the application handles routing using Angular's html5Mode. (e.g.: routes like example.com/this and example.com/that are handled by the js application in index.html)

Using Google Cloud Storage's website configuration this is all well and good, except that routes that are accessed directly ("example.com/this") will 404 as they obviously do not map to a file.

I have set my 404 page to be my index page, but what I really need in order to run a single page application in html5Mode is that such routes ("example.com/this") will not return a 404 header - they will simply be handled by index.html and return a success header (200).

Is this possible?


Solution

  • Unfortunately, this isn't really possible. Google Cloud Storage's web mapping is pretty simple, and you can't create arbitrary rules based on patterns and the like.

    You might want to consider either disabling html5mode or forcing a hashbang with html5mode. See this answer for more on that option.