Google Appengine trying to serve me files instead of a route

63 views
Skip to first unread message

Amiran G

unread,
Oct 8, 2020, 7:22:14 PM10/8/20
to Google App Engine
Hi,

I've got a node server (express) that needs to serve files from Storage. The url would look something like example.com/thumbnails/filename.jpg

I have registered a route with express for /thumbnails/:id which works fine locally on my computer, but on appspot.com it will try to serve me a static file instead, which it will not find. I will get a 404 error without the server handler ever being invoked.

I have a running server with a debug route here: https://fiid-ee.ey.r.appspot.com/api/test/asdasda

The above URL works fine and the handler should just respond with whatever is after test/

If you add a .jpg extension, the server will give me a 404: https://fiid-ee.ey.r.appspot.com/api/test/asdasdasd.jpg

Again, I tested this locally and it doesn't seem to be a feature of the server. The 404 page itself is not something implemented in Express nor Nuxt.js

Olu

unread,
Oct 12, 2020, 1:15:15 PM10/12/20
to Google App Engine
Hello, 

Just for better understanding, do you mean you are looking to have your App Engine application serve files from Google Cloud Storage[1]? I am not sure about the Storage you referenced in the first line of description "I've got a node server (express) that needs to serve files from Storage". Which Storage? Cloud Storage?

C Mos

unread,
Oct 12, 2020, 7:14:42 PM10/12/20
to Google App Engine
Hello,

" I've got a node server (express) that needs to serve files from Storage "

So from what I understand, your express server is dynamically serving files from your storage. Is this storage referring to storage attached to the instance? Or are you dynamically  returning a link to Google Cloud Storage? I am just asking something that it is not clear in the information that you provided but it will help to address your main question.

I would like to share that GAE has a feature to serve static files which you should evaluate in your use case. For instance, instead of using the above "storage", you can upload these resources with your application (when you deploy your application in GAE) and you will need to modify your app.yml file to indicate what files/folder should be managed statically. This means google will deliver the files without calling your application using their cache assigned to this service(GAE). This has two benefits: Faster delivery times for this resource and no bandwidth cost as your application is not called to delivered these static resources but it is managed by Google internal infrastructure. You can learn more about this here[1]. Based on this information, I hope you can evaluate if serving static resources suits your use case.


[1] See static_dir and static_files entries here: https://cloud.google.com/appengine/docs/standard/nodejs/config/appref

Jofre Riba Sanchez

unread,
Oct 23, 2020, 10:11:06 AM10/23/20
to Google App Engine
The Appengine docs explain that using express to serve files is for local development [1], hence why it works on your local environment.

Reply all
Reply to author
Forward
0 new messages