【问题标题】:Firebase Functions: the rewrites do nothingFirebase 功能:重写什么都不做
【发布时间】:2018-08-19 15:56:20
【问题描述】:

我尝试按照本教程使用 Angular Universal(服务器端渲染包)建立一个博客:https://hackernoon.com/deploy-angular-universal-w-firebase-ad70ea2413a1

/dist 文件夹似乎得到了服务,如果我不从中删除 index.html,它会正确地服务于非预呈现的应用程序。但是为了获得预渲染的应用程序,我应该删除 index.html。正如我在控制台输出中看到的那样,这也可以 - 我收到类似

的电话
[hosting] Rewriting / to live function ssr
[hosting] Rewriting /favicon.ico to live function ssr

但它们都超时了。我以为我的 index.js 有问题,所以我用一个假人替换它(来自 google 的 firebase 教程):

const functions = require('firebase-functions');
exports.ssr = functions.https.onRequest((req, res) => {
    const hours = (new Date().getHours() % 12) + 1; // london is UTC + 1hr;
    res.status(200).send(`<!doctype html>
    <head>
      <title>Time</title>
    </head>
    <body>
      ${'BONG '.repeat(hours)}
    </body>
  </html>`);
});

仍然没有响应,我在浏览器中遇到超时。当我执行curl -v 时,我得到:

curl http://localhost:5000 -v
* Rebuilt URL to: http://localhost:5000/
*   Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 5000 failed: Connection refused
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 5000 (#0)
> GET / HTTP/1.1
> Host: localhost:5000
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 504 Gateway Timeout
< Date: Sun, 11 Mar 2018 15:12:11 GMT
< Connection: keep-alive
< Content-Length: 42
<
* Connection #0 to host localhost left intact
Timed out waiting for function to respond

我该如何继续调试呢?我正在使用 firebase serve 在本地测试所有内容,但我在远程部署时遇到了同样的问题

【问题讨论】:

    标签: angular firebase google-cloud-functions


    【解决方案1】:

    firebase serve --only functions,hosting 怎么样? AFAIK firebase serve 仅运行未设置功能的托管模块(即使它们在配置中指定)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-05
      • 1970-01-01
      • 1970-01-01
      • 2018-12-17
      • 2020-01-16
      • 1970-01-01
      相关资源
      最近更新 更多