I am hosting a Flutter web app on Google Cloud Storage which works fine and is accessible via my sub domain app.mydomain.com
. In general i'm pretty happy with Google Cloud Storage since it is easy to deploy and the costs of hosting are cheap.
Unfortunately, routing is a problem.
When i navigate via the app to the login page the address bar changes to app.mydomain.com/login
and the login page is shown. But when i reload the page via the browser's reload button, I see the following XML
<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
</Error>
I assume this is because Google Cloud Storage wants to fetch the index.html file in the login
folder. However, the bucket does not contain such a login
folder.
Well, I figured out the problem.
If you pay close attention the the URL which i've posted in the question you might notice that the URL lacks the #
character which is normally present. This is because i've had set setPathUrlStrategy()
from the url_strategy
package.
So instead of using app.mydomain.com/login
my URL now looks like this app.mydomain.com/#/login
which causes Google Cloud storage to correctly forward the URL to my application instead of trying to fetch a file or folder within the bucket.