how to return a 204 response code in firebase hosting (node.js)

≯℡__Kan透↙ 提交于 2021-02-05 07:24:25

问题


Need some help. I am trying to access a file on firebase hosting with an android application, the application is downloading a .txt file and for verification reasons, before starting the download, it should check if the server is reachable, it needs a 204 response code (no content).

I can do it in PHP like so: (https://www.yourserver.com/return204.php):

<? php http_response_code(204); ?>

I found this link, but its looks very complicated: Firebase HTTP Functions, compared to the PHP solution. How can i do it in Firebase with Firebase Cloudfunctions or maybe simpler. Thanks


回答1:


Use this...

res.status(204).end();

Here is the full function...

exports.MyFunction = functions.https.onRequest((req, res) => {

   res.status(204).end();

});


来源:https://stackoverflow.com/questions/48529975/how-to-return-a-204-response-code-in-firebase-hosting-node-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!