Skip to content

Instantly share code, notes, and snippets.

@InputNeuron
Created February 24, 2020 05:38
Show Gist options
  • Select an option

  • Save InputNeuron/7179ed533f4ed3ae303d4f5862d124ce to your computer and use it in GitHub Desktop.

Select an option

Save InputNeuron/7179ed533f4ed3ae303d4f5862d124ce 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', 'xxxxxxxxx'));
// 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