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:
This is my file structure:
In the folder test_2023_11_03_c there is a file "index.html"
But it doesn't work.
For
- https://storage.googleapis.com/my-bucket-name, I expect to get the main
index.html
served. However, instead I get a list of all files in the bucket. - https://storage.googleapis.com/my-bucket-name/something-that-doesnt_exist, I expect the content of my_error.html to be served. However, instead I get
<?xml version='1.0' encoding='UTF-8'?><Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Details>No such object: my-bucket-name/something-that-doesnt_exist</Details></Error>
- https://storage.googleapis.com/my-bucket-name/test_2023_11_03_c, I expect the content of the directory's index.html to be served. However, instead I get the same error:
<?xml version='1.0' encoding='UTF-8'?><Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Details>No such object: my-bucket-name/test_2023_11_03_c</Details></Error>
What am I doing wrong?
You are trying to access files without a custom domain. Hence, You are experiencing this behavior. It is stated in the documentation that:
Also check this document to set a website configuration for a bucket.