1

I am using Google Cloud Functions with a custom domain to fire the functions. I then realized something so bad during execution. With the normal URL (https://us-central1-project.cloudfunctions.net/function), my request maintains its headers and body and I can get the data sent to my function.

However, after redirection using firebase, all the requests are GET requests with content-type as text/plain and no data in that; completely empty.

Is there a way that I could get this data in my cloud functions while still using a custom URL for my function?

While looking for this, I came across this question >> Use a custom domain for Google Cloud Function << that I answered on how I have added my custom URL. This is exactly how I am using it.

Here is my debugging code for the function

def function(request)

    content_type = request.headers['content-type']
    data = "not processed"

    if 'application/json' in content_type:
        data = str( request.get_json(force=True) )
    elif 'text/plain' in content_type:
        data = request.data.decode()
    else:
        return redirect('https://tradingview.to')

    print(data)
    return data
Lucem
  • 2,912
  • 3
  • 20
  • 33

0 Answers0