Convert SPA to SSR using Firebase #16837
-
I'm trying to install a Quasar APP using SSR into a Firebase, however I'm not sure how to do this in the firebase functions, I'm stuck. Right now when I try to access the Firebase function in emulator mode, I got a Cannot GET / here my files:
functions/index.js
Please let me know if I need to share any other information |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 9 replies
-
You can update // remove async modifier
export function listen ({ app, port, isReady }) {
// returns { handler: ... } without Promise on production
if (process.env.PROD) {
return { handler: functions.https.onRequest(app) }
}
// returns a promise only on development
return isReady().then(() => {
return app.listen(port, () => {
console.log('Server listening at port ' + port)
})
})
} functions/index.js const { handler } = require('./dist/ssr').default
// no need for `functions.https.onRequest` again since it's in src-ssr/server.js already
export.ssr = handler |
Beta Was this translation helpful? Give feedback.
-
Hello, thanks for helping me. After I fixed your suggestions, I'm still stuck. After the fixes, I've tested using Firebase functions emulators, accessing this URL http://127.0.0.1:5001/essencia-bahiana/us-central1/ssr and I got and error on screen: Cannot GET / Not sure if this is the way I'm supposed to test this. this is my first time trying a SSR app. I've also deployed the Build to firebase hosting, and as a suggestion from GPT, added the build inside the functions folder. Not sure if all this is needed. the Quasar dev ssr is working properly, but the production is not. in production I'm receiving this error: Error: Forbidden |
Beta Was this translation helpful? Give feedback.
-
I was able to fix all of that. First I fixed the code as you pointed in your first comment: and don't need to import render and recall it again so it is working, matter of fact, the pieces missing on the quasar Docs, were that you need to add the files for your build in your Functions folder, and alo all dependencies for the project. |
Beta Was this translation helpful? Give feedback.
-
I have spent quite a bit of time using quasar ssr with firebase, but no success after many days; I thought the best way to show you is to record my screen and show you what I have done. I would appreciate anyone taking a look at this: I also shared firebas.json; server.js, and functions/index.js for your reference. Any help would be appreciated. server.js
functions/index.js
|
Beta Was this translation helpful? Give feedback.
-
@joaoluizmagalhaes I totally understand and thank you for the response. I believe I am already doing this. Would you mind taking a look at this short video here: Recorded Screen |
Beta Was this translation helpful? Give feedback.
I was able to fix all of that.
First I fixed the code as you pointed in your first comment:
Second, you need to pass ssrHandler not the app:
return { handler: functions.https.onRequest(ssrHandler) }
and don't need to import render and recall it again
so it is working, matter of fact, the pieces missing on the quasar Docs, were that you need to add the files for your build in your Functions folder, and alo all dependencies for the project.