Yogesh Patil
Yogesh Patil

Reputation: 586

Google Cloud Storage custom error messages

I am using Google cloud storage as CDN to store file for our website which is hosted on Fastly.

In case of PDF files, we are doing a redirect to URL of PDF file in google cloud storage. Everything works fine except in case if the user manipulates the file location in URL (which is used to build create google storage object URL). In such case google storage display error message in XML format as follow:

<Error>
   <Code>NoSuchKey</Code>
   <Message>The specified key does not exist.</Message>
</Error>

Such message is fine for dev environments however on production this is not something we can show to the user in a browser. So I want to understand is there any provision in Google cloud storage to customize these messages and pages.

Thanks in advance,

Yogesh

Upvotes: 1

Views: 1545

Answers (1)

Brandon Yarbrough
Brandon Yarbrough

Reputation: 38379

The best way I know of to avoid this error would be to use GCS's static website hosting feature. To do so, you'd purchase some domain name, create a GCS bucket that matches that domain name, then specify the "NotFoundPage" property of the website configuration to be an object with whatever you'd like the appropriate error to be. The main downside here is that this would only work over HTTP, not HTTPS.

For more on how to set up static website config, see https://cloud.google.com/storage/docs/hosting-static-website

Upvotes: 3

Related Questions