![](/img/trans.png)
[英]How to deploy Nuxt SSR app to firebase through cloud functions?
[英]How to enable Vuex in Firebase Functions when deploying Nuxt app
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功能控制台說:
FATAL Enable vuex store by creating store/index.js.
在我的store
文件夾中,我有幾個用於 vuex 空間的文件,我在那里創建了 index.js 文件並嘗試了有無內容,但結果是一樣的。
我在部署函數之前所做的是將 generate.nuxt 文件夾復制到函數文件夾中:
npm run build && rm -rf functions/nuxt && cp -r .nuxt/ functions/nuxt/ && cp nuxt.config.js functions/
之后,這是函數文件夾結構:
這是函數內部 nuxt 文件夾的結構:
正如您在 nuxt 文件夾中看到的那樣,沒有 store 文件夾,只有一個 store.js 文件,閱讀它我發現它說:
store = normalizeRoot(require('../store/index.js'), 'store/index.js')
但是存儲文件夾是兩個文件夾,在根文件夾中,所以我將其更改為:
store = normalizeRoot(require('../../store/index.js'), 'store/index.js')
並嘗試手動部署功能,但結果是相同的錯誤消息。
我不知道如何在 Firebase 函數的服務器端啟用 Vuex,我認為通過更改store.js
文件可以解決它,但我需要在每次部署中更改它。 解決它的正確方法是什么? 謝謝。
到現在我已經通過將我的store/
文件夾復制到functions/
文件夾來解決它,現在 Firebase Functions 控制台什么也沒說,它看起來像工作,但我不確定它是否是解決它的正確方法。
我已將我的預部署命令更改為如下所示:
rm -rf functions/nuxt && cp -r .nuxt/ functions/nuxt/ && cp nuxt.config.js functions/ && cp -r store/ functions/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.