그래프큐엘로 구글 로그인 질문있습니다.
현재 아래와 같은 에러를 마주쳤습니다.
my-server_1 | TypeError: res.setHeader is not a function
my-server_1 | at JwtGoogleStrategy.strategy.redirect (/myFolder/node_modules/passport/lib/middleware/authenticate.js:340:13)
my-server_1 | at stored (/myFolder/node_modules/passport-oauth2/lib/strategy.js:285:14)
my-server_1 | at NullStore.store (/myFolder/node_modules/passport-oauth2/lib/state/null.js:5:3)
my-server_1 | at JwtGoogleStrategy.OAuth2Strategy.authenticate (/myFolder/node_modules/passport-oauth2/lib/strategy.js:297:28)
my-server_1 | at attempt (/myFolder/node_modules/passport/lib/middleware/authenticate.js:378:16)
my-server_1 | at authenticate (/myFolder/node_modules/passport/lib/middleware/authenticate.js:379:7)
my-server_1 | at /myFolder/node_modules/@nestjs/passport/dist/auth.guard.js:88:3
my-server_1 | at new Promise (<anonymous>)
my-server_1 | at /myFolder/node_modules/@nestjs/passport/dist/auth.guard.js:80:83
my-server_1 | at GqlAuthGuard.canActivate (/myFolder/node_modules/@nestjs/passport/dist/auth.guard.js:44:32)제 코드는 다음과 같습니다.
auth.resulver.ts 파일의 일부분입니다.
@UseGuards(GqlAuthGuard('google'))
@Mutation(() => String)
loginGoogle(
@Context() context: IContext, //
): void {
console.log('context::', context);
}그래프큐엘 가드 부분입니다.
import { ExecutionContext } from '@nestjs/common'; import { GqlExecutionContext } from '@nestjs/graphql'; import { AuthGuard } from '@nestjs/passport'; // graphql 인가 가드 설정 export const GqlAuthGuard = (name: string) => { return class GqlAuthGuard extends AuthGuard(name) { getRequest(context: ExecutionContext) { const gqlContext = GqlExecutionContext.create(context); return gqlContext.getContext().req; } }; };
jwt google 부분입니다.
import { PassportStrategy } from '@nestjs/passport';
import { Strategy } from 'passport-google-oauth20';
export class JwtGoogleStrategy extends PassportStrategy(Strategy, 'google') {
constructor() {
super({
clientID: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
callbackURL: 'http://localhost:3001/login',
scope: ['email', 'profile'],
});
}
validate(accessToken, profile) {
console.log('profile:', profile);
return {
...
};
}
}
혹시 제가 실수한 부분이있을까요?
답변 3
0
안녕하세요! 반가우면반갑다고해님!
맨 위의 에러 내용을 보니, res.setHeader is not a function 이라고 되어 있네요!
res 부분에 context.res가 제대로 전달되고 있는지 확인이 필요할 것 같아요!
만약, 제대로 전달되고 있는 것 같다면, 추가적으로 app.module에서 GraphqlModule의 context 설정에서 req, res가 제대로 전달되고 있는지 확인해 주세요!
GraphQLModule.forRoot<ApolloDriverConfig>({ context: ({ req, res }) => ({ req, res }), // req는 기본적으로 들어오지만, res는 이걸 작성해야만 들어옴 }),
0
SITUS SLOT GACOR TERBAIK DAN TERPERCAYA

FURI88 : DAFTAR LINK SLOT GACOR TERBAIK
HARI INI
Menyediakan beragam jenis permainan GAME SLOT Terlengkap dan tergacor
Pragmatic Play | PG soft | spadeGaming | JOKER | Habanero | NoLimit | PlayStar,
NextSpin | AdvantPlay | Microgaming | FLOW Gaming | CQ9 Gaming | Red Tiger -
dan masih banyak Provider Game Slot tergacor lainnya.
https://loftiespacesandevents.com/
https://www.ivermectinoral.com/
https://slotgacor-7oa.pages.dev/
https://slot-gacor-dse.pages.dev/
https://furi88win.tumblr.com/
#FURI88 #FURI88 SLOT GACOR #FURI88 SITUS SLOT
윈도우에서 Node js를 설치하고 싶어요
0
9
0
그래프 ql 문서 사용할때 느낌표 남는거 어떻게 없애나요?
0
102
2
강의 전체 소스 코드를 받고싶습니다.
0
92
2
fontawesome 사용 문의
0
96
2
소스 코드 부탁드립니다~
0
99
2
깃 레포지터리 소스
0
96
2
커리큘럼12.css 정렬 에 나오는 과제 정답알고싶어요
0
81
2
10-01 Entity TypeOrmModule.forRoot 에 entities
0
101
3
강의 버전관련 문의입니다
0
111
2
Ubuntu 설치 관련
0
73
1
schema.gql 질문 드립니다.
0
63
1
서버 재실행시 Many to Many
0
119
3
input 관련 문의
0
97
2
Rest API 보다는 graphql이 주된 내용인데
0
145
2
강의 전체 소스코드 받을수있을까요?
0
170
1
도커볼륨 마운트 관련
0
136
2
findOne 타입스크립트오류
0
116
1
http => htrtps 호출 인증서 신뢰 오류
0
374
1
self-signed certificate in certificate chain 에러 발생
0
439
1
mongoose 설치 오류
0
149
1
특정 API, 특정 IP 허용 (단일경로에 CORS 활성화)
0
300
2
08-06
0
188
3
구조랑 패턴 관련해서 질문
0
134
2
mydocker
0
135
2





