Skip to content

Instantly share code, notes, and snippets.

@InputNeuron
Created February 24, 2020 14:53
Show Gist options
  • Select an option

  • Save InputNeuron/7cf56ea9a93c1442d17b5e5cf7321a91 to your computer and use it in GitHub Desktop.

Select an option

Save InputNeuron/7cf56ea9a93c1442d17b5e5cf7321a91 to your computer and use it in GitHub Desktop.
import {createWebapp} from "../../webapp/Webapp";
import * as functions from "firebase-functions";
import express from 'express';
const app = createWebapp();
app.use(require('prerender-node').set('prerenderToken', 'xxxx'));
// https://expressjs.com/en/guide/error-handling.html
// add a better error handler
app.use(function(err: Error, req: express.Request, res: express.Response, next: express.NextFunction) {
console.error("Could not handle SSR: \n" + err.stack);
if (res.headersSent) {
return next(err);
}
res.status(500).send('Internal Server Error');
});
export const SSRFunction = functions.https.onRequest(app);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment