Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while deploying react based SSR app, using firebase-functions

I am trying to deploy my SSR app in firebase originally forked from https://github.com/subhendukundu/template-react-ssr/tree/feature/react-router, after doing some modification in the app. Which works fine when I do sudo firebase serve --only functions,hosting but throwing error when I do firebase deploy. The reproducible repo is https://github.com/subhendukundu/template-react-ssr/tree/feature/react-router, which has a package.json https://github.com/subhendukundu/template-react-ssr/tree/feature/react-router/public I am using the public directory as my function directory as well, https://github.com/subhendukundu/template-react-ssr/blob/feature/react-router/firebase.json. However, even if I am using a different function directory for my cloud functions, I see the same errors. Is there anyway I can fix it?

like image 272
Subhendu Kundu Avatar asked Jan 24 '19 05:01

Subhendu Kundu


People also ask

Does firebase support SSR?

Firebase Hosting serves only static assets. It does not in any way interpret the files that it servers. The only way to get the code in interpreted server-side is by linking Firebase Hosting with Cloud Functions, or Cloud Run. If you don't want to do that, there's no way to get SSR on Firebase Hosting.

Can I use firebase with Express?

Serverless APIs and your First Endpoint. Firebase Functions enables you to use the ExpressJS library to host a Serverless API.

Can we Host dynamic website on firebase?

Stay organized with collections Save and categorize content based on your preferences. Firebase Hosting provides fast and secure hosting for your web app, static and dynamic content, and microservices.


1 Answers

It is possible, but you cannot serve static assets with cloud functions. You need a mix of firebase functions and firebase hosting.

The guys at Firebase already thought on this and you also have an implementation available.

Check the following documentation:

  • Overview
  • Dynamic Content
  • Code Example
  • Youtube Video

Note: There is a delay that you need to take into consideration when using cloud functions.

When a new instance handles its first request, the response time suffers, which is called a cold start

More info

like image 168
ajorquera Avatar answered Sep 18 '22 04:09

ajorquera