1
votes

I want to run an Node.js app on the GCP, while having only the scripts uploaded to the App Engine. All the static files are to be placed inside a bucket in Cloud Storage, for easier manipulation. While the app is running on https://netwell.digital, all the static files are to be found inside https://netwell.digital/static/.

So far I have found contradicting info on this and Google Cloud Platform itself only goes as far as:

You can now access your static assets via https://storage.googleapis.com//static/...

Is there a way to have the bucket mapped as this /static/ directory of an App Engine application?

1
Why don't you just use the bucket url for the image directly? Or a lookup table, so when the page requests https://sparkx.online/static/..., it is replaced by the bucket url? - GAEfan
Pointing to the bucket url directly is the most cumbersome and least elegant way linking to static resources inside a bucket I could think of. Repeating the full absolute https://storage.googleapis.com/.. for every resource inside every page and css is quite nasty. Replacing a placeholder string with the bucket URL server-side is just as unreasonable, plus it cannot be done with files such as CSSs and scripts inside the bucket and doing that client-side is totally a no go. I can't imagine there is no way to have a bucket mapped as a directory for an App Engine app. - marko-36
Update: A way to do someting similar is to create a CNAME record on the domain to point sometinhg like "static.netwell.digital" to "storage.googleapis.com" and so being able to access the bucket files on static.netwell.digital/<unique-bucket-name>, but is there really no way to place static files in the traditional directory structure within the same domain? - marko-36

1 Answers

2
votes

The way you want it to function is possible using Cloud Storage bucket to host a static website. But you have to choose serving your website from App Engine or a bucket. As you find the documentation serving static file it is the way you access, it seems not possible how you wanted it to be.