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?
- 3,270
- 4
- 19
- 53
-
Would next.js fix this? – Subhendu Kundu Feb 14 '19 at 11:19
-
Could you add the error message that you are getting? – Agney Feb 14 '19 at 12:34
-
`Function failed on loading user code. Error message: Code in file index.js can't be loaded. Is there a syntax error in your code? Detailed stack trace: TypeError: c(...) is not a function at Object.
(/user_code/assets/app.server.js:1:28950) at Object.module.exports.n (/user_code/assets/app.server.js:1:29283) . . . . Functions deploy had errors. To continue deploying other features (such as database), run: firebase deploy --except functions Error: Functions did not deploy properly.` – Subhendu Kundu Feb 14 '19 at 13:04 -
Any suggestion looking at the error? – Subhendu Kundu Feb 14 '19 at 17:01
-
1@SubhenduKundu today you asked a [question](https://stackoverflow.com/questions/64074523/how-to-make-gird-with-fixed-numbers-of-columns-and-rows-always), I successfully solved that but you deleted that post so I am requesting you to re-post the same question... _**Plz tell me if you have already solved that**_ – carl johnson Sep 26 '20 at 12:20
-
@carl Stackoverflow was suggesting it was duplicate and was asking me to delete the post, that was the reason I deleted no other intention. I thought it's a bad community practice having duplicate questions. I don't mind putting it back, if that helps – Subhendu Kundu Sep 26 '20 at 16:05
-
https://stackoverflow.com/questions/52861086/how-come-minmax0-1fr-works-for-long-elements-while-1fr-doesnt – Subhendu Kundu Sep 26 '20 at 16:09
-
This was the solution. – Subhendu Kundu Sep 26 '20 at 16:09
-
okay........... – carl johnson Sep 26 '20 at 17:19
2 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:
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
- 1,138
- 20
- 25
The problem is that firebase hosting only supports SPAs, which means that SSR is out of the picture, you need to run your SSR server in a different env where you can run nextJS, or if you're using a static page generator you could upload the files directly compromising on the ability to refresh the content, although, I'm sure a solution with cloud functions and gatsby is feasable.
Tl;DR: You won't get SSR out of Firebase Hosting
- 548
- 2
- 12
-
1I am using firebase functions https://github.com/subhendukundu/template-react-ssr/blob/feature/react-router/firebase.json. I am assuming SSR is posible using functions as https://howtofirebase.com/firebase-ssr-starter-7dde175a0dbc – Subhendu Kundu Feb 27 '19 at 06:30
-
are you using uglify or minification on your firebase functions? as I mentioned above, it is possible to do SSR with firebase functions, and now with a little more context, I can see that you're working on top of a boilerplate. Make sure you are using the right features for the node version(6) that firebase functions use, also, you don't need to minify or transpile backend code unless you want to go through the trouble. – Jose Munoz Feb 27 '19 at 19:07
-
I tried both minified and unminified code, same issue. Now about the node version, if the code minified I am guessing doesnt matter, does it? – Subhendu Kundu Feb 27 '19 at 19:24