Closed bananaappletw closed 2 years ago
Hey @grant, could you add some context to the history of this here? This may be related #191
The URL path favicon.ico
returns a 404 to prevent double invocation of a user function when invoking via a HTTP browser. Serverless functions should really just handle 1 endpoint for 1 function.
It's typically recommended that you don't use the literal URL path as an input to your function, at least as an input to another URL.
Could your function use a HTTP query param instead, such as localhost:8080/?path=myURL/foo.txt
? I believe this should solve the use-case.
I believe the alternative implementation should satisfy the use-case. LMK if that doesn't work. Closing as WAI but feel free to comment with requested changes and I can re-open if needed.
@grant Thank you for explanation.
Could your function use a HTTP query param instead
No, I used cloud function as a reverse proxy without any manipulation on the URL.
My intent is that a cloud function should be able dealing with the original request without any extra logic attached on it.
To follow up here, Cloud Functions is meant to serve and invoke a single function when receiving a HTTP request. The URL path should not be part of the logic of the function. For example, Cloud Functions Gen 1 and Gen 2 have different URL paths.
For this use-case of using URL paths within the function, I would consider using express directly with Cloud Run and not using the Functions Framework.
Hi @grant I am running into this problem.
Would it be possible to have some configuration option to disable this very specific behaviour where Google Cloud http triggered functions object to serving /favicon.ico
The Google Cloud Firebase documentation has examples of using a Google Cloud Function to host an express web app which literally relies on the URL path - which is at odds with your statement:
the URL path should not be part of the logic of the function
https://firebase.google.com/docs/hosting/functions#use_a_web_framework
I use cloud function as a reverse proxy between client(browser) and GCS bucket.
Fetch the GCS bucket object and create readable stream to pipe to client.
When I request
/favicon.ico
it returns 404.There's an existing logic to return 404 for
/favicon.ico|/robots.txt
.Ref: https://github.com/GoogleCloudPlatform/functions-framework-nodejs/blob/07668f696b29f077d4ba9d0463ea994076cdab50/src/server.ts#L122+L125
I haven't thought about the solution which also fulfill the original purpose, just to provide my use case.
Ref: https://github.com/GoogleCloudPlatform/functions-framework-nodejs/pull/193
Thank you.