I'm trying to deploy a Nuxt SSR app to Firebase Functions to be served from the client and server side, everything works as expected but when trying to implement @nuxtjs/auth
it works locally but not when deployed to Firebase, looking into the Firebase Functions console it says:
FATAL Enable vuex store by creating store/index.js.
In my store
folder I have several files for vuex spaces, I've created the index.js file there and tried with and without content but result is the same.
What I do before deploying the functions is to copy the generated .nuxt folder into functions folder:
npm run build && rm -rf functions/nuxt && cp -r .nuxt/ functions/nuxt/ && cp nuxt.config.js functions/
After that, this is the functions folder structure:
And this is the structure of nuxt folder inside functions:
As you can see inside the nuxt folder there is not a store folder, just a store.js file, reading it I've found it says:
store = normalizeRoot(require('../store/index.js'), 'store/index.js')
But store folder is two folders back, in the root folder, so I've changed it to:
store = normalizeRoot(require('../../store/index.js'), 'store/index.js')
And tried to deploy functions manually, but result is the same error message.
I don't know what to do to enable Vuex in the server side of Firebase functions, I think that by changing the store.js
file I could solve it, but I would need to change it in every deployment. What is the correct way to solve it? Thanks.