firebase store추가
async function signInWithGoogle(): Promise<void> {
const provider = new GoogleAuthProvider();
try {
const signInResult = await signInWithPopup(FirebaseClient.getInstance().Auth, provider);
if (signInResult.user) {
const resp = await fetch('/api/members.add', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
uid: signInResult.user.uid,
email: signInResult.user.email,
displayName: signInResult.user.displayName,
photoURL: signInResult.user.photoURL,
}),
});
console.info({ status: resp.status });
const respData = await resp.json();
console.info(respData);
}
} catch (err) {
console.error(err);
}
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import type { NextApiRequest, NextApiResponse } from 'next';
import { FirebaseAdmin } from '../../models/firebase_admin';
export default async function handler(
req: NextApiRequest,
res: NextApiResponse,
) {
const { uid, displayName, photoURL, email } = req.body;
if (uid === undefined || uid === null) {
return res.status(400).json({ result: false, message: 'uid가 누락되었습니다.' });
}
try {
const addResult = await FirebaseAdmin.getInstance().Firebase.collection('members').add({
uid,
email: email ?? '',
displayName: displayName ?? '',
photoURL: photoURL ?? '',
});
return res.status(200).json({ result: true, id: addResult });
} catch (error) {
console.error(error);
res.status(500).json({ result: false });
}
firebase 에 members가 추가가 안됩니다..
code: 16,
details: 'Failed to retrieve auth metadata with error: error:0909006C:PEM routines:get_name:no start line',
metadata: Metadata { internalRepr: Map(0) {}, options: {} },
note: 'Exception occurred in retry method that was not classified as transient'
stackoverflow 에서도 찾아보고 있는데 혹시 해결방법이 있을까요
}
}
답변 2
0
- 새로운 사용자 추가 되었습니다.
2. 터미널에 찍히는 오류 입니다.
firebase 설정 테스트서버 쪽으로 안돌아가있던건지..
서버 설정 다시 하니까 작동 됩니다.
감사합니다.
0
Eli님 안녕하세요.
앞에서부터 진행이 잘 되지 않아 속상하셨겠네요.
어느 부분에서 안되시는지 확인이 필요해서 질문 몇가지 남깁니다.
1. 로그인을 진행하면 firebase authentication에 새로운 사용자가 추가되어 있나요?
2. 해당 에러는 브라우저에서 나는 건가요? 아니면 next.js를 실행한 터미널에 찍히는 오류인가요?
답변 남겨주시면 저도 단서를 얻을 수 있겠네요.
강의 소제목
0
466
1
배포 관련 질문
0
650
1
Error: Illegal url for new iframe
0
765
1
빌드 오류(babel-eslint -> @babel/eslint-parser)
0
1182
2
강의 관련 질문입니다!
0
383
1
useState의 set 함수에 대해서 질문이 있습니다.
0
482
1
아직 못 들었는데 듣기 시작한 날부터 수강기한 시작할 수 없을까요?
0
346
1
사용하시는 zsh 테마가 뭐예요?
0
467
2
1월 21일까지 수강기간인데
0
370
1
Module not found: Can't resolve 'fs' 오류
0
2148
1
publicRunTimeConfig error
0
342
1
강의 수강일 문의 드립니다.
0
311
2
https://bit.ly/broken-link 관련 CORS 오류해결
0
307
1
useToast 에러
0
597
1
문의 드립니다😭
0
230
1
빌드시 오류
0
309
1
vercel 배포 후 list의 uid가 넘어가지 않아 문의 드립니다!
1
546
1
CORS 오류로 인한 문의 드립니다
0
314
1
LOCAL_CHROME_PATH 경로에 파일이 없어요!
0
360
1
렌더마다 변경되는 값이라서 context Provider에 못 넣는 에러
0
240
1
public runtime config 에러 공유
0
349
1
컴포넌트 파일명에 underscore
0
315
1
firebase admin 코드 추가 강의 부분
7
445
2
구글 로그인 apikey error
0
371
3





