question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deployed functions req.method not correct for HEAD requests

See original GitHub issue

Version info

firebase-functions: 2.0.3

firebase-tools: 6.1.1

firebase-admin: 6.0.0

node engine: bug appeared in 6 and 8 express: 4.16.3

Test case

Making a head request with curl -I to an express route, while serving locally the req.method is ‘HEAD’. Once deployed however, it is ‘GET’. This is an issue, because I am tracking downloaded files and I don’t want to count head requests which do not download the file.

Steps to reproduce

index.ts:

const echoMethod = (req, res) => {
  const request = {
    method: req.method,
    path: req.path
  }
  return admin.firestore().collection('reqTest').add(request).then(() =>
    res.sendStatus(200);
  ).catch(err => 
    res.sendStatus(500);
  );
}

const testApp = express();
testApp.all('/all', echoMethod);
// have also tried testApp.head(), but same result

const app = express();
app.use('/api', testApp);
export const test = functions.https.onRequest(app);

Then send curl request: curl -I https://myfirebaseapp.com/api/all

Were you able to successfully deploy your functions?

No errors, deploy successful

Expected behavior

req.method should be ‘HEAD’ for head requests. When served locally, this works properly. After deployment, it is recorded as ‘GET’.

Actual behavior

req.method for head request is recorded as ‘GET’.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
thechenkycommented, May 29, 2019

Hi @inorganik, this requires some discussion with our partner teams, let me check on that for you. Will post back with any updates.

1reaction
thechenkycommented, Dec 14, 2018

Hi @inorganik thanks for the feature request. We are trying not to keep Github issues open if we’re not actively working on them and they are not actual bugs. However, we hear you that this support should exist. I have filed an internal ticket for this request, reference bug 121049520. I’m going to close this out meanwhile.

Read more comments on GitHub >

github_iconTop Results From Across the Web

In Express JS, post() method is working perfectly in firebase ...
I have one post() and get() request in Express JS. My post() request is not working in local machine.It is throwing 404 error...
Read more >
Write HTTP functions | Cloud Functions Documentation
Cloud Functions automatically parses the request body for you based on the request's Content-Type header using body-parser , so you can access the...
Read more >
Azure Functions HTTP trigger | Microsoft Learn
The HTTP trigger lets you invoke a function with an HTTP request. You can use an HTTP trigger to build serverless APIs and...
Read more >
Set up a method request in API Gateway - AWS Documentation
You can set up the ANY method on a non-proxy resource as well. Combining the ANY method with a proxy resource, you get...
Read more >
7 HTTP methods every web developer should know and how ...
Next, make a GET request for that resource, and ensure the data was saved correctly. Add tests that ensure POST requests fail with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found