我可以使用Firebase Hosting在Node.js中编写RESTful API [英] Can I use Firebase Hosting to write a RESTful API in Node.js

查看:72
本文介绍了我可以使用Firebase Hosting在Node.js中编写RESTful API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们以server.js Hello World为例

Let's take for example the server.js Hello World

  var http = require("http");
  http.createServer(function(request, response) {
    response.writeHead(200, {"Content-Type": "text/plain"});
    response.end("Hello World");
  }).listen(80);

如何在Firebase中使用它?

How can I use it in Firebase ?

很抱歉重复,但答案是3yo

Sorry for the duplicate but the answers were 3yo

推荐答案

(更新:现在的答案是:是的,您可以-看到下面的更新)

不,您不能. Firebase托管仅用于静态内容.

No, you can't. Firebase hosting is only for static content.

请参阅: https://firebase.google.com/docs/hosting/

Firebase托管为您的Web应用程序提供了快速,安全的静态托管.

Firebase Hosting provides fast and secure static hosting for your web app.

您需要诸如Heroku之类的可以运行Node应用程序的服务,或者需要您自己的服务器来安装Node并运行您的应用程序.

You need either a service like Heroku that can run your Node app, or you need your own server where you will install Node and run your app.

现在,您可以直接在Firebase上托管Node应用程序了-感谢 Ayyappa 在注释中指出了这一点.

Now you can host your Node apps on Firebase directly - thanks to Ayyappa for pointing it out in the comments.

观看此出色的视频教程:

See this excellent video tutorial:

和文档:

Firebase云功能可让您自动运行后端代码,以响应由Firebase功能和HTTPS请求触发的事件.您的代码存储在Google的云中,并在托管环境中运行.无需管理和扩展自己的服务器.

Cloud Functions for Firebase lets you automatically run backend code in response to events triggered by Firebase features and HTTPS requests. Your code is stored in Google's cloud and runs in a managed environment. There's no need to manage and scale your own servers.

请注意,它仍处于Beta版:

这是Google Cloud Functions的Beta版.该API可能会以向后不兼容的方式更改,并且不受任何SLA或弃用政策的约束.

This is a Beta release of Google Cloud Functions. This API might be changed in backward-incompatible ways and is not subject to any SLA or deprecation policy.

这篇关于我可以使用Firebase Hosting在Node.js中编写RESTful API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆