GCP Console Bugs
1
Google Cloud Platform (GCP) has a service called storage which can be useful for hosting static websites.
Simply create a ‘bucket’ with the name of your domain (e.g. example1.com) and update your DNS for that domain to be a CNAME pointing to ‘c.storage.googleapis.com’.
Navigating to your domain will then server the index.html file at that path in th bucket.
I stumbled across a bug almost right way however.
When I uploaded my website to the bucket, I used the GCP console and drag&dropped the websites files all in one go into the bucket.
While it uploaded with no errors, when I tested the site, it was broken.
CSS failed to be applied and navigating to certain pages would download them rather than render them.
The issue turned out to be the MIME type of those files.
GCP tries to be clever and set the MIME type it is going to send the file as based on the file extension. Whether it is because it didn’t recognize some file types or because to upload the files it creates an octet stream, GCP was getting confused and setting the MIME type of some CSS and HTML files to ‘application/octet-stream’ rather than the correct ’text/css’ and ’text/html’ respectively.
There are a number of workarounds including uploading the files one at a time.
As there were a fair number of files this was not a practical solution so I ended up using the cli tool ‘gsutil’ with the command ‘gsutil rsync -d -r <local folder> gs://<GCP bucket>’.