简体   繁体   English

Firebase云功能在本地运行,但在部署后不运行

[英]Firebase cloud functions work locally but not after deployment

I'm currently attempting to deploy a Nuxt SSR app to Firebase. 我目前正在尝试将Nuxt SSR应用部署到Firebase。

Everything works correctly on local and the firebase server. 一切都在本地和firebase服务器上正常工作。 The cloud function correctly executes and renders the html, no problem. 云功能正确执行并呈现html,没问题。

The problem happens when I add a request to and external API (Storyblok). 当我向外部API(Storyblok)添加请求时,会出现问题。 I'm on the Blaze plan so external requests should work, right? 我正在使用Blaze计划,所以外部请求应该有效,对吗?

Everything works on local using the cloud functions emulator and through firebase serve --only functions,hosting with the external API request but I get an error 500 after deploying. 一切都在本地使用云功能模拟器和firebase serve --only functions,hosting外部API请求,但部署后我得到一个错误500。

Is there a way to get a more detailed log of what may be happening on the Firbase end? 有没有办法获得Firbase端可能发生的更详细的日志?

Cloud Function: 云功能:

const functions = require('firebase-functions');
const { Nuxt } = require('nuxt');
const express = require('express');
const app = express();

const config = {
  dev: false,
  buildDir: 'nuxt',
  build: {
    publicPath: '/assets/'
  }
}
const nuxt = new Nuxt(config);

function handleRequest(req, res) {
  res.set('Cache-Control', 'public, max-age=150, s-maxage=150');
  return new Promise((resolve, reject) => {
    nuxt.render(req, res, promise => {
      promise.then(resolve).catch(reject)
    })
  });
}

app.use(handleRequest);
exports.nuxtssr = functions.https.onRequest(app);

Try to add debug: true in your Nuxt config. 尝试在Nuxt配置中添加debug: true

ie

const config = {
  debug: true,
  dev: false,
  buildDir: 'nuxt',
  build: {
    publicPath: '/assets/'
  }
}

This will make the error message shows in browser, instead of just error 500. 这将使错误消息显示在浏览器中,而不仅仅是错误500。

Referring you to : 引用你:

https://firebase.google.com/docs/functions/writing-and-viewing-logs#viewing_logs https://firebase.google.com/docs/functions/writing-and-viewing-logs#viewing_logs

perhaps this would have more details using Using the Firebase CLI. 也许这将使用使用Firebase CLI获得更多详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM