Skip to content

Commit dc2d948

Browse files
committed
implement serverApp in nextjs-end
1 parent ddc901f commit dc2d948

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

nextjs-end/src/lib/firebase/serverApp.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,19 @@ import { firebaseConfig } from "./config";
99
import { getAuth } from "firebase/auth";
1010

1111
export async function getAuthenticatedAppForUser() {
12-
throw new Error('not implemented');
12+
const idToken = headers().get("Authorization")?.split("Bearer ")[1];
13+
14+
const firebaseServerApp = initializeServerApp(
15+
firebaseConfig,
16+
idToken
17+
? {
18+
authIdToken: idToken,
19+
}
20+
: {}
21+
);
22+
23+
const auth = getAuth(firebaseServerApp);
24+
await auth.authStateReady();
25+
26+
return { firebaseServerApp, currentUser: auth.currentUser };
1327
}

nextjs-start/src/lib/firebase/serverApp.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,5 @@ import { firebaseConfig } from "./config";
99
import { getAuth } from "firebase/auth";
1010

1111
export async function getAuthenticatedAppForUser() {
12-
const idToken = headers().get("Authorization")?.split("Bearer ")[1];
13-
console.log('firebaseConfig', JSON.stringify(firebaseConfig));
14-
const firebaseServerApp = initializeServerApp(
15-
firebaseConfig,
16-
idToken
17-
? {
18-
authIdToken: idToken,
19-
}
20-
: {}
21-
);
22-
23-
const auth = getAuth(firebaseServerApp);
24-
await auth.authStateReady();
25-
26-
return { firebaseServerApp, currentUser: auth.currentUser };
12+
throw new Error('not implemented');
2713
}

0 commit comments

Comments
 (0)