GCP static website hosting via bucket does not serve configured error and index pages

180 views Asked by At

I'm trying to serve a simple static React SPA through GCP bucket as described here: https://cloud.google.com/storage/docs/hosting-static-website

It is crucial for my structure that for /my_directory, the file /my_directory/index.html is served.

I think what I want is exactly described here in the "Three-object bucket" in the documentation

This is my config:

enter image description here

This is my file structure:

enter image description here

In the folder test_2023_11_03_c there is a file "index.html"

But it doesn't work.

For

What am I doing wrong?

1

There are 1 answers

0
Roopa M On BEST ANSWER

You are trying to access files without a custom domain. Hence, You are experiencing this behavior. It is stated in the documentation that:

The MainPageSuffix and NotFoundPage website configurations are only used for requests that come to Cloud Storage through a CNAME or A redirect. For example, a request to www.example.com shows the index page, but an equivalent request to storage.googleapis.com/www.example.com does not.

Thus, API behavior for requests to Cloud Storage domains, such as storage.googleapis.com/www.example.com, is preserved. For example, you can continue to list objects in the www.example.com bucket as you would for any other bucket. In the case of the www.example.com bucket, the object listing you receive includes 404.html and index.html

Also check this document to set a website configuration for a bucket.