An Next.js example repo for building authenticated pages with Firebase Authentication, cookies, and getServerSideProps
by colinhacksTypeScript
Unhandled Runtime Error TypeError: Cannot read properties of undefined (reading 'apps') Call Stack eval webpack-internal:///./firebaseClient.js (25:68) ./firebaseClient.js file:///D:/WORK/PROJECTS/PAID/dashboard-forex/.next/static/chunks/pages/management/transactions.js (2412:1) options.factory /_next/static/chunks/webpack.js (621:31) __webpack_require__ file:///D:/WORK/PROJECTS/PAID/dashboard-forex/.next/static/chunks/webpack.js (37:33) fn /_next/static/chunks/webpack.js (276:21) eval webpack-internal:///./src/layouts/SidebarLayout/Header/Userbox/index.js (19:72) ./src/layouts/SidebarLayout/Header/Userbox/index.js file:///D:/WORK/PROJECTS/PAID/dashboard-forex/.next/static/chunks/pages/management/transactions.js (2599:1) options.factory /_next/static/chunks/webpack.js (621:31) __webpack_require__ file:///D:/WORK/PROJECTS/PAID/dashboard-forex/.next/static/chunks/webpack.js (37:33) fn /_next/static/chunks/webpack.js (276:21) eval webpack-internal:///./src/layouts/SidebarLayout/Header/index.js (11:66) ./src/layouts/SidebarLayout/Header/index.js file:///D:/WORK/PROJECTS/PAID/dashboard-forex/.next/static/chunks/pages/management/transactions.js (2610:1) options.factory /_next/static/chunks/webpack.js (621:31) __webpack_require__ file:///D:/WORK/PROJECTS/PAID/dashboard-forex/.next/static/chunks/webpack.js (37:33) fn /_next/static/chunks/webpack.js (276:21) eval webpack-internal:///./src/layouts/SidebarLayout/index.js (8:65) ./src/layouts/SidebarLayout/index.js file:///D:/WORK/PROJECTS/PAID/dashboard-forex/.next/static/chunks/pages/management/transactions.js (2643:1) options.factory /_next/static/chunks/webpack.js (621:31) __webpack_require__ file:///D:/WORK/PROJECTS/PAID/dashboard-forex/.next/static/chunks/webpack.js (37:33) fn /_next/static/chunks/webpack.js (276:21) eval webpack-internal:///./pages/management/transactions/index.js (6:83) ./pages/management/transactions/index.js file:///D:/WORK/PROJECTS/PAID/dashboard-forex/.next/static/chunks/pages/management/transactions.js (2445:1) options.factory /_next/static/chunks/webpack.js (621:31) __webpack_require__ file:///D:/WORK/PROJECTS/PAID/dashboard-forex/.next/static/chunks/webpack.js (37:33) fn /_next/static/chunks/webpack.js (276:21) eval node_modules\next\dist\build\webpack\loaders\next-client-pages-loader.js?absolutePagePath=D%3A%5CWORK%5CPROJECTS%5CPAID%5Cdashboard-forex%5Cpages%5Cmanagement%5Ctransactions%5Cindex.js&page=%2Fmanagement%2Ftransactions! (5:15) eval node_modules\next\dist\client\route-loader.js (235:50)
I followed the example and redirected when the page isn't authenticated: https://github.com/colinhacks/next-firebase-ssr/blob/master/pages/authenticated.tsx#L25 As a result, when I load my website for the first time in a while, it redirects to /404. When I reload my authenticated page it works (bc the website regenerates my token). Is there any way to resolve this? What's the preferred way to refresh your token? This is my full error message:
Thanks so much for this very helpful example repo. I wanted to leave a note here (since it was where I initially searched for the solution) that the cookie name is not compatible as of writing with Firebase's experimental support for turnkey Next.js deployments. This is because Firebase Functions only accept one cookie by the name of . (SO source) While the example provided in this repo worked fine in development, the call to would fail in production due to Firebase stripping the cookie. I switched the saved cookie's name to in both the and in and that resolved the issue for me, not sure if there are any potential pitfalls of doing this.
Repository: colinhacks/next-firebase-ssr. Description: An Next.js example repo for building authenticated pages with Firebase Authentication, cookies, and getServerSideProps Stars: 426, Forks: 57. Primary language: TypeScript. Homepage: https://vriad.com/essays/nextjs-firebase-authentication Topics: authentication, firebase, firebase-auth, nextjs, ssr. Open PRs: 2, open issues: 8. Last activity: 3y ago. Top contributors: colinhacks, ivanjeremic, stephensilber, subwaymatch, imjared, wRWebDev.