Each time I attempt to send a HTTP POST request to my Firebase Function, I receive an error in my browser console, a status 503 error.
I am attempting the post request from a squarespace website in chrome browser. I am sending the exact same information that was sent when using Heroku as 'middleware' for the POST requests from this page. It is a very basic JSON string. Example below.
{ "to": ["ExponentPushToken[dhLJeWNqW61r1ZBUkAwOtA]"], "title": "Hello World! ", "body": "I am Mark Logue, and I made this app!", "sound": "default", "data": {"event": ""} }
The website I am sending the post request from is on my cors-anywhere whitelist with the index.js file.
There are two concerning logs that I found within the Firebase Function (Google Cloud) logs for this function. First when I look at the log for the POST request, it shows in initial Options status of 204, see the log below:
{ "insertId": "6372a16400076996e307afbc", "httpRequest": { "requestMethod": "OPTIONS", "requestUrl": "https://proxy-hwp6dcya3a-uc.a.run.app/https://exp.host/--/api/v2/push/send", "requestSize": "761", "status": 204, "responseSize": "863", "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36", "remoteIp": "47.149.74.45", "referer": "https://restoredtemecula.church/", "serverIp": "216.239.36.53", "latency": "1.341490290s", "protocol": "HTTP/1.1" }, "resource": { "type": "cloud_run_revision", "labels": { "configuration_name": "proxy", "location": "us-central1", "revision_name": "proxy-hvnfg", "service_name": "proxy", "project_id": "restored-temecula-mobile-app" } }, "timestamp": "2022-11-14T20:13:24.485782Z", "severity": "INFO", "labels": { "instanceId": "0074e2ccb212737e5aad036cd3cebcfe4d5f35f47d168e939180e59572278e50b0cb6b75be2da34e4a6c16bbab33905987e3d9640d703e97d54f9708a58c14dc9f29", "goog-managed-by": "cloudfunctions" }, "logName": "projects/restored-temecula-mobile-app/logs/run.googleapis.com%2Frequests", "trace": "projects/restored-temecula-mobile-app/traces/ca1ce4c9d9432e0ab47d756bff0cf16c", "receiveTimestamp": "2022-11-14T20:13:24.492659539Z", "spanId": "14113124528369450882", "traceSampled": true }
Second, I receive in the 503 status error both in the logs in firebase function (google cloud) and in my chrome browser (logging the server response for the POST request). Here is the firebase funciton/google cloud log for the 503 status:
{ "insertId": "6372a177000a1e8dbb2702ed", "httpRequest": { "requestMethod": "POST", "requestUrl": "https://proxy-hwp6dcya3a-uc.a.run.app/https://exp.host/--/api/v2/push/send", "requestSize": "1171", "status": 503, "responseSize": "1201", "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36", "remoteIp": "47.149.74.45", "referer": "https://restoredtemecula.church/", "serverIp": "216.239.36.53", "latency": "19.114303071s", "protocol": "HTTP/1.1" }, "resource": { "type": "cloud_run_revision", "labels": { "location": "us-central1", "configuration_name": "proxy", "service_name": "proxy", "revision_name": "proxy-hvnfg", "project_id": "restored-temecula-mobile-app" } }, "timestamp": "2022-11-14T20:13:43.663181Z", "severity": "ERROR", "labels": { "instanceId": "0074e2ccb212737e5aad036cd3cebcfe4d5f35f47d168e939180e59572278e50b0cb6b75be2da34e4a6c16bbab33905987e3d9640d703e97d54f9708a58c14dc9f29", "goog-managed-by": "cloudfunctions" }, "logName": "projects/restored-temecula-mobile-app/logs/run.googleapis.com%2Frequests", "trace": "projects/restored-temecula-mobile-app/traces/9dacc5993e58e51bcd37c3c3b8b461e6", "receiveTimestamp": "2022-11-14T20:13:43.670755140Z", "spanId": "17443868335897408337" }
![Untitled 5](https://user-images.githubusercontent.com/83615439/201766216-6d21e065-bcc9-4de1-a4e4-617a08d98905.png)
Lastly, when I attempt to perform the POST request in terminal using CURL, I receive the same response as if I were simply navigate to the link (https://proxy-hwp6dcya3a-uc.a.run.app/https://exp.host/--/api/v2/push/send) in my browser. E.g below shows the CURL command follow by the response, directly copied from terminal and pasted here.
curl -H "Content-Type: application/json" -X POST "https://proxy-hwp6dcya3a-uc.a.run.app/https://exp.host/--/api/v2/push/send" -d '{ "to": "ExponentPushToken[dhLJeWNqW61r1ZBUkAwOtA]", "title":"hello", "body": "world" }' Missing required request header. Must specify one of: origin,x-requested-with%
"Missing required request header. Must specify one of: origin,x-requested-with"... Would love any assistance on this! Thanks in advance!