HTTP错误:400,hosting.rewrites [0]不是[subschema 0],[subschema 1]

时间:2018-02-18 21:19:39

标签: javascript reactjs firebase google-cloud-functions firebase-cli

使用firebase deploy时出现以下错误:

Error: HTTP Error: 400, hosting.rewrites[0] is not exactly one from [subschema 0 ],[subschema 1]

enter image description here

这会导致什么?

我的函数文件index.js

const functions = require('firebase-functions');
const nodemailer = require('nodemailer');

import React from 'react';
import { renderToString } from 'react-dom/server';
import express from 'express';
import fs from 'fs';
import App from './app/containers/App';

const index = fs.readFileSync(__dirname + '/index.html', 'utf8');

const app = express();

app.get('**', (req, res) => {
  const html = renderToString(<App />);
  const finalHtml = index.replace('app', html);
  res.set('Cache-Control', 'public, max-age=600, s-maxage=1200');
  res.send(finalHtml);
});

export const ssrapp = functions.https.onRequest(app);

exports.someCustomFunction1 = functions.database.ref(...).onWrite(...);
exports.someCustomFunction2 = functions.database.ref(...).onWrite(...);

firebase.json

{
  "hosting": {
    "public": "build",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "ssrapp"
      }
    ]
  }
}

由于

1 个答案:

答案 0 :(得分:3)

将网址重写为云功能的配置需要一对sourcefunction。目前您正在展示一对sourcedestination,因此您应该将destination更改为functionPlease see the documentation了解更多详情。