webcore-it / nuxt2-ssr-on-firebase

Example for hosting a Nuxt.js 2.0 ssr app on Google Firebase
26 stars 6 forks source link

Got 500 when deployed on Firebase #6

Closed WeAspireDev closed 6 years ago

WeAspireDev commented 6 years ago

When I first tried to deploy it. I got an error for async await and deployment failed. So I have added

 "engines": {
    "node": "8"
  },

in function's package.json. I have also upgraded Firebase admin, function and Vuetify to the latest version. When I deployed this I saw in the Stackdriver logs it never got the callback from nuxt.render

function handleRequest(req, res) {
  // Set the cache time to a low number to get a response from the server and not us the
  // cached content in your browser.
  // Or do not cache the ssr response at all.
  res.set('Cache-Control', 'public, max-age=1, s-maxage=1'); // set time to 1sec for this example
  return new Promise((resolve, reject) => {
    console.log('Return promise') //=============> this shows in th log
    nuxt.render(req, res, (promise) => {
      console.log('Got nuxt.render response') //=============> but this doesn't
      promise.then(resolve).catch(reject);
    });
  });
}

Could you please help me to fix this? Thanks!

PS:- I am on node 8.12

webcore-it commented 6 years ago

@WeAspireDev I also updated the project to be able to use Node.js 8 on Firebase Functions.

Have a look at the updates pls: https://github.com/webcore-it/nuxt2-ssr-on-firebase/pull/10/commits/45a09d25cee5f6f89ed9d2d0a4a0ff2272bf4bab https://github.com/webcore-it/nuxt2-ssr-on-firebase/pull/10/commits/db79bd5ed84be51d6a84b33a66fe4fcd4fcfce10

Output of the GitLab pipeline

=== Deploying to 'nuxt2-example-dev'...

i  deploying functions, hosting
i  functions: ensuring necessary APIs are enabled...
✔  functions: all necessary APIs are enabled
i  functions: preparing functions directory for uploading...
i  functions: packaged functions (3.11 MB) for uploading
✔  functions: functions folder uploaded successfully
i  hosting[nuxt2-example-dev]: beginning deploy...
i  hosting[nuxt2-example-dev]: found 27 files in public
i  hosting: uploading new files [4/27] (14%)
✔  hosting[nuxt2-example-dev]: file upload complete
i  functions: updating Node.js 8 function ssrapp(us-central1)...      <------------
i  functions: updating Node.js 8 function getRedVsBlue(us-central1)...      <------------
✔  functions[getRedVsBlue(us-central1)]: Successful update operation. 
✔  functions[ssrapp(us-central1)]: Successful update operation. 
i  hosting[nuxt2-example-dev]: finalizing version...
✔  hosting[nuxt2-example-dev]: version finalized
i  hosting[nuxt2-example-dev]: releasing new version...
✔  hosting[nuxt2-example-dev]: release complete

✔  Deploy complete!

Firebase Console - Functions

The Firebase Console shows both functions with Runtime Node.js 8: image

The logs show both functions: image

WeAspireDev commented 6 years ago

Thanks a lot! for taking out the time to update the template. It is working as expected!