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?
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.
Serverless APIs and your First Endpoint. Firebase Functions enables you to use the ExpressJS library to host a Serverless API.
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.
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:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With