인프런 커뮤니티 질문&답변

박호정님의 프로필 이미지

작성한 질문수

[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스

13-01 Single Image Upload

post 요청시 헤더 관련 에러

해결된 질문

작성

·

406

1

 post 요청시 헤더 관련 아래 에러 발생하는데, apollo-require-preflight: true등을 넣으면 정상 작동 하네요. 혹시 이 에러가 강의 중에는 안 나던데, 이유 알 수 있을까요?

 

{
    "errors": [
        {
            "message": "This operation has been blocked as a potential Cross-Site Request Forgery (CSRF). Please either specify a 'content-type' header (with a type that is not one of application/x-www-form-urlencoded, multipart/form-data, text/plain) or provide a non-empty value for one of the following headers: x-apollo-operation-name, apollo-require-preflight\n",
            "extensions": {
                "code": "BAD_REQUEST",
                "stacktrace": [
                    "BadRequestError: This operation has been blocked as a potential Cross-Site Request Forgery (CSRF). Please either specify a 'content-type' header (with a type that is not one of application/x-www-form-urlencoded, multipart/form-data, text/plain) or provide a non-empty value for one of the following headers: x-apollo-operation-name, apollo-require-preflight",
                    "",
                    "    at new GraphQLErrorWithCode (/Users/hojeongpark/Develop/study/backend-bootcamp/class/section13/13-01-single-image-upload/node_modules/@apollo/server/src/internalErrorClasses.ts:15:5)",
                    "    at new BadRequestError (/Users/hojeongpark/Develop/study/backend-bootcamp/class/section13/13-01-single-image-upload/node_modules/@apollo/server/src/internalErrorClasses.ts:116:5)",
                    "    at preventCsrf (/Users/hojeongpark/Develop/study/backend-bootcamp/class/section13/13-01-single-image-upload/node_modules/@apollo/server/src/preventCsrf.ts:91:9)",
                    "    at ApolloServer.executeHTTPGraphQLRequest (/Users/hojeongpark/Develop/study/backend-bootcamp/class/section13/13-01-single-image-upload/node_modules/@apollo/server/src/ApolloServer.ts:1047:20)",
                    "    at processTicksAndRejections (node:internal/process/task_queues:95:5)"
                ]
            }
        }
    ]
}

답변 1

1

노원두님의 프로필 이미지
노원두
지식공유자

안녕하세요! 호정님!

apollo 버전이 올라가면서 발생한 문제인 것 같아요!

아래 링크에 왜 이러한 문제가 발생하였는지에 관한 자세한 설명이 포함되어있습니다!^^

https://www.inflearn.com/questions/840954