Reputation: 390
I have a node/express app on App Engine Standard. If I serve the static files using express.static everything works as expected.
Now, I want to reduce the overhead on the app by serving of static files as described here: https://cloud.google.com/appengine/docs/standard/serving-static-files?tab=node.js#serving_from_your_application
So far, no luck getting this to work. I'm hoping someone can see where I'm going wrong.
The deployed directory structure is:
App Engine:/
/dist
/public
/img
/node_modules
/src
...
and I'm trying to serve images so that www.my_app.com/img/picture.jpg doesn't hit express.static with this in my app.yaml:
handlers:
- url: /img
static_dir: dist/public/img
- url: /.*
script: auto
The images are all returning 404 errors. The handler url is matching correctly because the app engine log has this warning:
Static file referenced by handler not found: /dist/public/img/picture.jpg
The app.yaml docs (https://cloud.google.com/appengine/docs/standard/reference/app-yaml?tab=node.js) state that static_dir is "The path to the directory containing the static files, from the application root directory."
I'm assuming the application root directory would be App Engine:/ but just in case, I also tried defining static_dir as
static_dir: public/img
which also doesn't work.
So, I'm missing something important and it's driving me bananas :(
Upvotes: 1
Views: 202