Skip to content

Commit

Permalink
Ssr update (#250)
Browse files Browse the repository at this point in the history
* feat: environment aware

* fix: update dependencies

* fix: import

* fix: remove package lock

* Delete nextjs-end/.firebase/hinamomori-0x/functions/package-lock.json

* Delete nextjs-end/.firebase/hinamomori-0x/functions/.env

* Delete nextjs-end/.firebase/hinamomori-0x/functions/package.json

* Delete nextjs-end/.firebase/hinamomori-0x/functions/server.js

* fix: typo

* fix: header when disabling javascript

* fix: storage rules

* fix: update firebase

* fix: remove console logs
  • Loading branch information
HYACCCINT authored Sep 15, 2023
1 parent 4a12f50 commit 91deaa2
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions nextjs-end/src/lib/firebase/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ export const db = getFirestore(firebaseApp);
export const storage = getStorage(firebaseApp);

// For development purposes only
connectFirestoreEmulator(db, "127.0.0.1", 8080);
connectStorageEmulator(storage, "127.0.0.1", 9199);
connectAuthEmulator(auth, "http://127.0.0.1:9099", {
disableWarnings: true,
});
// connectFirestoreEmulator(db, "127.0.0.1", 8080);
// connectStorageEmulator(storage, "127.0.0.1", 9199);
// connectAuthEmulator(auth, "http://127.0.0.1:9099", {
// disableWarnings: true,
// });

export async function getAuthenticatedAppForUser(session = null) {

Expand All @@ -39,15 +39,19 @@ export async function getAuthenticatedAppForUser(session = null) {

return { app: firebaseApp, user: auth.currentUser.toJSON() };
}
// import {initializeApp as initializeAdminApp, getApps as getAdminApps} from "firebase-admin/app";

const { initializeApp: initializeAdminApp, getApps: getAdminApps } = await import("firebase-admin/app");

const { getAuth: getAdminAuth } = await import("firebase-admin/auth");

const { credential } = await import("firebase-admin");

const ADMIN_APP_NAME = "firebase-frameworks";
const adminApp =
getAdminApps().find((it) => it.name === ADMIN_APP_NAME) ||
initializeAdminApp({}, ADMIN_APP_NAME);
initializeAdminApp({
credential: credential.applicationDefault(),
}, ADMIN_APP_NAME);

const adminAuth = getAdminAuth(adminApp);
const noSessionReturn = { app: null, currentUser: null };
Expand Down

0 comments on commit 91deaa2

Please sign in to comment.