묻고 답해요
161만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
해결됨Slack 클론 코딩[백엔드 with NestJS + TypeORM]
try문 밖에서 에러 발생시 트랜잭션이 release가 안됩니다.
12:00 시작된 join 매서드를 만들고 실행을 시켜보니 에러 처리를 하면 커넥션 pool이 종료되지 않는거 같습니다. 이메일이 중복된 user를 insert하려 할 때 new ForbiddenException이 실행이 됩니다. 하지만 finally문이 실행이 안되는거 같습니다.async join(email: string, nickname: string, password: string) { const queryRunner = this.dataSource.createQueryRunner(); await queryRunner.connect(); await queryRunner.startTransaction(); const user = await queryRunner.manager .getRepository(Users) .findOne({ where: { email } }); if (user) { throw new ForbiddenException('이미 존재하는 사용자입니다'); } const hashedPassword = await bcrypt.hash(password, 12); try { const returned = await queryRunner.manager.getRepository(Users).save({ email, nickname, password: hashedPassword, }); const workspaceMember = queryRunner.manager .getRepository(WorkspaceMembers) .create(); workspaceMember.User = returned.id; workspaceMember.Workspace = 1; // throw new NotFoundException('롤백해봐'); await queryRunner.manager .getRepository(WorkspaceMembers) .save(workspaceMember); await queryRunner.manager.getRepository(ChannelMembers).save({ User: returned.id, ChannelId: 1, }); await queryRunner.commitTransaction(); return true; } catch (error) { console.error(error); await queryRunner.rollbackTransaction(); throw error; } finally { console.log('이거 실행됨?'); await queryRunner.release(); } }'이거 실행됨?' 이라는 문자가 출력이 되지 않습니다. 여러번 반복한 후 pgAdmin에서 database activity를 살펴보니 커넥션 pool이 release되지 않고 idle 상태로 되어있습니다.이 때문에 서버의 pool이 가득차서 서버가 종료됩니다. user의 중복검사도 try문 안에 넣으면 해결되는거 같습니다. 🟩 혹시 존재하는 사용자 로직을 try문 밖에 빼신 이유가 있는지 궁금합니다.
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 프론트엔드 코스
삭제하기 기능 구현 레퍼런스 코드는 없을까요
게시글 상세 화면에서 삭제하기 기능을 구현해주세요.이부분에 대한 레퍼런스 코드가 깃허브에 등록된 내용에는 나오지 않는데 알고 싶습니다
-
해결됨한 입 크기로 잘라 먹는 리액트(React.js) : 기초부터 실전까지
리액트 프로젝트 생성시 질문
npx-create 시 에러나서user/Appdata/Roaming 경로 아래 npm폴더를 생성하고 재수행했더니 작동했는데 이유가 궁금합니다. 그리고 강사님께서 하시는 방법으로 바꿀수 있는 방법은 없을까요...? 매번 appdata로 가서 폴더 선택하는것이 번잡스러워서요...
-
해결됨한 입 크기로 잘라 먹는 리액트(React.js) : 기초부터 실전까지
props 사용 시 중괄호 질문
props를 사용해 전달 받을 때 어떤 상황에서 중괄호를 사용하고 특히 함수를 전달 받을 때 왜 중괄호가 필요한지 궁금합니다.const DiaryEditor = ({onCreate}) => {return} const DiaryList = ({diaryList}) => {return} const DiaryItem = ({author, content, create_date, emotion, id}) => {return}
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 프론트엔드 코스
css in js 관련 질문드립니다!
안녕하세요! 현재 리액트 초반부 강의 수강중에 있습니다.포트폴리오 코딩중에 있는데 css in js 에서 일반적인 css에서 처럼 전체선택자 *를 사용하여box-sizing: border-box; 로 하고싶은데 검색하봐도 방법이 나오지 않습니다.. css in js 에서 전체선택자는 어떤식으로 사용할 수 있을까요?MDN 처럼 css in js 관련 아카이브가 따로 있을까요?
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
nestjs+graphql로 작업할때 response도 dto로 만들어야하나요?
선생님, 질문두가지 드릴게요, 감사합니다1. nestjs+graphql로 작업할때 response도 dto로 만들어야하나요?2. class-validator를 entity에서 사용하고 dto를 pick, omit으로 상속받는게 좋나요? 아니면 dto들에서 따로 class-validator를 적용하는게 좋나요?
-
해결됨한 입 크기로 잘라 먹는 리액트(React.js) : 기초부터 실전까지
코드 중에 질문이 있어요 ..
아래 코드에서 ${emotion} 으로 쓰는것과 그냥 {strDate}랑 하나는 $를 쓰고 하나는 안쓰는거같은데 이거 어떨떄 차이가 나는지좀 알수있을까요??import { useEffect, useState, useContext } from "react"; import MyButton from "./MyButton"; import { useNavigate } from "react-router-dom"; const DiaryItem = ({ id, emotion, content, date }) => { console.log(process.env.PUBLIC_URL + `/assets/emotion${emotion}.png`); const strDate = new Date(parseInt(date)).toLocaleDateString(); const goDetail = () => { Navigate(`/diary${id}`); }; const goEdit = () => { Navigate(`/edit${id}`); }; return ( <div className="DiaryItem"> <div onClick={goDetail} className={[ "emotion_img_wrapper", `emotion_img_wrapper_${emotion}`, ].join(" ")} > <img src={process.env.PUBLIC_URL + `assets/emotion${emotion}.png`} /> </div> <div className="info_wrapper"> <div className="diary_date">{strDate}</div> <div className="diary_content_preview">${content.slice(0, 25)}</div> </div> <div className="btn_wrapper"> <MyButton onClick={goEdit} text={"수정하기"} /> </div> </div> ); }; export default DiaryItem;
-
미해결탄탄한 백엔드 NestJS, 기초부터 심화까지
findCatByIdWithoutPassword 함수 리턴 타입 질문
async findCatByIdWithoutPassword(id: string): Promise<Cat | null> { const cat = await this.catModel.findById(id).select('-password'); return cat; } 위 함수에서 Pomise의 반환값이 Cat 또는 null인데 cat은 password가 없는 Cat이라서 Cat이라고 할 수 없는데 return을 cat으로 해도 에러가 안나는 이유를 알고 싶습니디.
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
도커의 데이터베이스 컨테이너와 nestjs typeORM이 어떤 방식으로 연동되는지 궁금해요
docker-compose 에 있는 my-database의 연결app.module.ts에 있는 typeOrmModule에 있는 데이터베이스 연결이 어떤 원리로 작동되는지 궁금합니다. my-database: image: mysql:latest environment: MYSQL_DATABASE: 'mydocker' MYSQL_ROOT_PASSWORD: 'root' ports: - 3306:3306TypeOrmModule.forRoot({ //.env 파일은 모두 string 형태로 인식이 됩니다. 따라서, type과 port에 추가 설정을 해주었습니다. type: mysql, host: "localhost", port: 3306, username: "root", password: "12345678", database: practice, entities: [Board], synchronize: true, logging: true, })
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 프론트엔드 코스
section27 퀴즈 질문입니다.
등록 시 화면 페이지는 바뀌는데 바뀌자마자 위와 같은 오류가 떠서 계속 찾아보는데 혼자는 해결하기 어려워 여쭤봅니다 ㅠㅠ 어디가 틀린 걸까요? mutation은 제대로 된 걸 확인했는데 fetch가 안 되네요.폴더 구조는05/boards/new index.js05/boards/products/[productId] index.jsimport { useState } from "react"; import { useMutation, gql } from "@apollo/client"; import { useRouter } from "next/router"; const CREATE_PRODUCT = gql` mutation createProduct( $seller: String $createProductInput: CreateProductInput! ) { createProduct(seller: $seller, createProductInput: $createProductInput) { _id number message } } `; export default function ProductRegPage() { const router = useRouter(); const [seller, setSeller] = useState(); const [name, setName] = useState(); const [detail, setDetail] = useState(); const [price, setPrice] = useState(); const [createProduct] = useMutation(CREATE_PRODUCT); const onClickRegister = async () => { try { const result = await createProduct({ variables: { seller, createProductInput: { name, detail, price, }, }, }); console.log(result); router.push(`/05/boards/products/${result.data.createProduct._id}`); } catch (error) { alert(error.message); } }; const onChangeSeller = (event) => { setSeller(event.target.value); }; const onChangeName = (event) => { setName(event.target.value); }; const onChangeDetail = (event) => { setDetail(event.target.value); }; const onChangePrice = (event) => { setPrice(parseInt(event.target.value)); }; return ( <div> 판매자: <input type="text" onChange={onChangeSeller} /> 상품명: <input type="text" onChange={onChangeName} /> 상품내용: <input type="text" onChange={onChangeDetail} /> 상품가격: <input type="text" onChange={onChangePrice} /> <button onClick={onClickRegister}>상품 등록</button> </div> ); } import { useQuery, gql } from "@apollo/client"; import { useRouter } from "next/router"; const FETCH_PRODUCT = gql` query fetchProduct($productId: ID) { fetchProduct(productId: $productId) { seller name detail price } } `; export default function ProductDetailPage() { const router = useRouter(); console.log(router); const { data } = useQuery(FETCH_PRODUCT, { variables: { productId: router.query.productId }, }); console.log(data); return ( <div> <div>판매자:{data ? fetchProduct?.seller : "loading..."}</div> <div>상품명:{data ? fetchProduct?.name : "loading..."}</div> <div>상품내용:{data ? fetchProduct?.detail : "loading..."}</div> <div>상품가격:{data ? fetchProduct?.price : "loading..."}</div> </div> ); }
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
CSS 정렬 강의 실습 중
코드 자동저장돼 있고 혹시몰라 수동저장 후 다시 라이브서버 켰는데 박스까지만 만들어지고 정렬이 전혀 되지 않으면서 아무 응답이 없는데 제가 혹시 코드를 잘못 쓴 부분이 있는걸까요?
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 프론트엔드 코스
.eslintrc.js module 키워드에 빨간밑줄
위와 같은 에러가 생기는데 규칙을 검사하는 건 문제가 없긴합니다. 에러 내용을 번역해서 봤는데도 무슨 말인지 잘 모르겠고 어떻게 해결해야하는지 감도 안옵니다..
-
미해결따라하며 배우는 노드, 리액트 시리즈 - 챗봇 사이트 만들기
npm start 에러
npm ERR! code 1npm ERR! path C:\Users\gjaischool\Desktop\x_test\chatbot-app-master\node_modules\grpcnpm ERR! command failednpm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node-pre-gyp install --fallback-to-build --library=static_librarynpm ERR! Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --library=static_library --module=C:\Users\gjaischool\Desktop\x_test\chatbot-app-master\node_modules\grpc\src\node\extension_binary\node-v115-win32-x64-unknown\grpc_node.node --module_name=grpc_node --module_path=C:\Users\gjaischool\Desktop\x_test\chatbot-app-master\node_modules\grpc\src\node\extension_binary\node-v115-win32-x64-unknown --napi_version=9 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v115' (1)npm ERR! node-pre-gyp info it worked if it ends with oknpm ERR! node-pre-gyp info using node-pre-gyp@0.12.0npm ERR! node-pre-gyp info using node@20.4.0 | win32 | x64npm ERR! node-pre-gyp WARN Using needle for node-pre-gyp https downloadnpm ERR! node-pre-gyp info check checked for "C:\Users\gjaischool\Desktop\x_test\chatbot-app-master\node_modules\grpc\src\node\extension_binary\node-v115-win32-x64-unknown\grpc_node.node" (not found)npm ERR! node-pre-gyp http GET https://node-precompiled-binaries.grpc.io/grpc/v1.19.0/node-v115-win32-x64-unknown.tar.gznpm ERR! node-pre-gyp http 404 https://node-precompiled-binaries.grpc.io/grpc/v1.19.0/node-v115-win32-x64-unknown.tar.gznpm ERR! node-pre-gyp WARN Tried to download(404): https://node-precompiled-binaries.grpc.io/grpc/v1.19.0/node-v115-win32-x64-unknown.tar.gznpm ERR! node-pre-gyp WARN Pre-built binaries not found for grpc@1.19.0 and node@20.4.0 (node-v115 ABI, unknown) (falling back to source compile with node-gyp) npm ERR! node-pre-gyp http 404 status code downloading tarball https://node-precompiled-binaries.grpc.io/grpc/v1.19.0/node-v115-win32-x64-unknown.tar.gznpm ERR! gyp info it worked if it ends with oknpm ERR! gyp info using node-gyp@9.4.0npm ERR! gyp info using node@20.4.0 | win32 | x64npm ERR! gyp info oknpm ERR! gyp info it worked if it ends with oknpm ERR! gyp info using node-gyp@9.4.0npm ERR! gyp info using node@20.4.0 | win32 | x64npm ERR! gyp ERR! find Pythonnpm ERR! gyp ERR! find Python Python is not set from command line or npm configurationnpm ERR! gyp ERR! find Python Python is not set from environment variable PYTHONnpm ERR! gyp ERR! find Python checking if "python3" can be usednpm ERR! gyp ERR! find Python - "python3" is not in PATH or produced an errornpm ERR! gyp ERR! find Python checking if "python" can be usednpm ERR! gyp ERR! find Python - "python" is not in PATH or produced an errornpm ERR! gyp ERR! find Python checking if Python is C:\Users\gjaischool\AppData\Local\Programs\Python\Python39\python.exenpm ERR! gyp ERR! find Python - "C:\Users\gjaischool\AppData\Local\Programs\Python\Python39\python.exe" could not be runnpm ERR! gyp ERR! find Python checking if Python is C:\Program Files\Python39\python.exenpm ERR! gyp ERR! find Python - "C:\Program Files\Python39\python.exe" could not be runnpm ERR! gyp ERR! find Python checking if Python is C:\Users\gjaischool\AppData\Local\Programs\Python\Python39-32\python.exenpm ERR! gyp ERR! find Python - "C:\Users\gjaischool\AppData\Local\Programs\Python\Python39-32\python.exe" could not be runnpm ERR! gyp ERR! find Python checking if Python is C:\Program Files\Python39-32\python.exenpm ERR! gyp ERR! find Python - "C:\Program Files\Python39-32\python.exe" could not be runnpm ERR! gyp ERR! find Python checking if Python is C:\Program Files (x86)\Python39-32\python.exenpm ERR! gyp ERR! find Python - "C:\Program Files (x86)\Python39-32\python.exe" could not be runnpm ERR! gyp ERR! find Python checking if Python is C:\Users\gjaischool\AppData\Local\Programs\Python\Python38\python.exenpm ERR! gyp ERR! find Python - "C:\Users\gjaischool\AppData\Local\Programs\Python\Python38\python.exe" could not be runnpm ERR! gyp ERR! find Python checking if Python is C:\Program Files\Python38\python.exenpm ERR! gyp ERR! find Python - "C:\Program Files\Python38\python.exe" could not be runnpm ERR! gyp ERR! find Python checking if Python is C:\Users\gjaischool\AppData\Local\Programs\Python\Python38-32\python.exenpm ERR! gyp ERR! find Python - "C:\Users\gjaischool\AppData\Local\Programs\Python\Python38-32\python.exe" could not be runnpm ERR! gyp ERR! find Python checking if Python is C:\Program Files\Python38-32\python.exenpm ERR! gyp ERR! find Python - "C:\Program Files\Python38-32\python.exe" could not be runnpm ERR! gyp ERR! find Python checking if Python is C:\Program Files (x86)\Python38-32\python.exenpm ERR! gyp ERR! find Python - "C:\Program Files (x86)\Python38-32\python.exe" could not be runnpm ERR! gyp ERR! find Python checking if Python is C:\Users\gjaischool\AppData\Local\Programs\Python\Python37\python.exenpm ERR! gyp ERR! find Python - "C:\Users\gjaischool\AppData\Local\Programs\Python\Python37\python.exe" could not be runnpm ERR! gyp ERR! find Python checking if Python is C:\Program Files\Python37\python.exenpm ERR! gyp ERR! find Python - "C:\Program Files\Python37\python.exe" could not be runnpm ERR! gyp ERR! find Python checking if Python is C:\Users\gjaischool\AppData\Local\Programs\Python\Python37-32\python.exenpm ERR! gyp ERR! find Python - "C:\Users\gjaischool\AppData\Local\Programs\Python\Python37-32\python.exe" could not be runnpm ERR! gyp ERR! find Python checking if Python is C:\Program Files\Python37-32\python.exenpm ERR! gyp ERR! find Python - "C:\Program Files\Python37-32\python.exe" could not be runnpm ERR! gyp ERR! find Python checking if Python is C:\Program Files (x86)\Python37-32\python.exenpm ERR! gyp ERR! find Python - "C:\Program Files (x86)\Python37-32\python.exe" could not be runnpm ERR! gyp ERR! find Python checking if Python is C:\Users\gjaischool\AppData\Local\Programs\Python\Python36\python.exenpm ERR! gyp ERR! find Python - "C:\Users\gjaischool\AppData\Local\Programs\Python\Python36\python.exe" could not be runnpm ERR! gyp ERR! find Python checking if Python is C:\Program Files\Python36\python.exenpm ERR! gyp ERR! find Python - "C:\Program Files\Python36\python.exe" could not be runnpm ERR! gyp ERR! find Python checking if Python is C:\Users\gjaischool\AppData\Local\Programs\Python\Python36-32\python.exenpm ERR! gyp ERR! find Python - "C:\Users\gjaischool\AppData\Local\Programs\Python\Python36-32\python.exe" could not be runnpm ERR! gyp ERR! find Python checking if Python is C:\Program Files\Python36-32\python.exenpm ERR! gyp ERR! find Python - "C:\Program Files\Python36-32\python.exe" could not be runnpm ERR! gyp ERR! find Python checking if Python is C:\Program Files (x86)\Python36-32\python.exenpm ERR! gyp ERR! find Python - "C:\Program Files (x86)\Python36-32\python.exe" could not be runnpm ERR! gyp ERR! find Python checking if the py launcher can be used to find Python 3npm ERR! gyp ERR! find Python - "py.exe" is not in PATH or produced an errornpm ERR! gyp ERR! find Pythonnpm ERR! gyp ERR! find Python **********************************************************npm ERR! gyp ERR! find Python You need to install the latest version of Python.npm ERR! gyp ERR! find Python Node-gyp should be able to find and use Python. If not,npm ERR! gyp ERR! find Python you can try one of the following options:npm ERR! gyp ERR! find Python - Use the switch --python="C:\Path\To\python.exe"npm ERR! gyp ERR! find Python (accepted by both node-gyp and npm)npm ERR! gyp ERR! find Python - Set the environment variable PYTHONnpm ERR! gyp ERR! find Python - Set the npm configuration variable python:npm ERR! gyp ERR! find Python npm config set python "C:\Path\To\python.exe"npm ERR! gyp ERR! find Python For more information consult the documentation at:npm ERR! gyp ERR! find Python https://github.com/nodejs/node-gyp#installationnpm ERR! gyp ERR! find Python **********************************************************npm ERR! gyp ERR! find Pythonnpm ERR! gyp ERR! configure errornpm ERR! gyp ERR! stack Error: Could not find any Python installation to usenpm ERR! gyp ERR! stack at PythonFinder.fail (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:330:47)npm ERR! gyp ERR! stack at PythonFinder.runChecks (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:159:21)npm ERR! gyp ERR! stack at PythonFinder.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:228:18)npm ERR! gyp ERR! stack at PythonFinder.execFileCallback (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-python.js:294:16)npm ERR! gyp ERR! stack at exithandler (node:child_process:427:5)npm ERR! gyp ERR! stack at ChildProcess.errorhandler (node:child_process:439:5)npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:512:28)npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:291:12)npm ERR! gyp ERR! stack at onErrorNT (node:internal/child_process:483:16)npm ERR! gyp ERR! stack at process.processTicksAndRejections (node:internal/process/task_queues:82:21)npm ERR! gyp ERR! System Windows_NT 10.0.22621npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--fallback-to-build" "--library=static_library" "--module=C:\\Users\\gjaischool\\Desktop\\x_test\\chatbot-app-master\\node_modules\\grpc\\src\\node\\extension_binary\\node-v115-win32-x64-unknown\\grpc_node.node" "--module_name=grpc_node" "--module_path=C:\\Users\\gjaischool\\Desktop\\x_test\\chatbot-app-master\\node_modules\\grpc\\src\\node\\extension_binary\\node-v115-win32-x64-unknown" "--napi_version=9" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v115"npm ERR! gyp ERR! cwd C:\Users\gjaischool\Desktop\x_test\chatbot-app-master\node_modules\grpcnpm ERR! gyp ERR! node -v v20.4.0npm ERR! gyp ERR! node-gyp -v v9.4.0npm ERR! gyp ERR! not oknpm ERR! node-pre-gyp ERR! build errornpm ERR! node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js configure --fallback-to-build --library=static_library --module=C:\Users\gjaischool\Desktop\x_test\chatbot-app-master\node_modules\grpc\src\node\extension_binary\node-v115-win32-x64-unknown\grpc_node.node --module_name=grpc_node --module_path=C:\Users\gjaischool\Desktop\x_test\chatbot-app-master\node_modules\grpc\src\node\extension_binary\node-v115-win32-x64-unknown --napi_version=9 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v115' (1)npm ERR! node-pre-gyp ERR! stack at ChildProcess.<anonymous> (C:\Users\gjaischool\Desktop\x_test\chatbot-app-master\node_modules\grpc\node_modules\node-pre-gyp\lib\util\compile.js:83:29)npm ERR! node-pre-gyp ERR! stack at ChildProcess.emit (node:events:512:28)npm ERR! node-pre-gyp ERR! stack at maybeClose (node:internal/child_process:1098:16)npm ERR! node-pre-gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:304:5)npm ERR! node-pre-gyp ERR! System Windows_NT 10.0.22621npm ERR! node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\gjaischool\\Desktop\\x_test\\chatbot-app-master\\node_modules\\grpc\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build" "--library=static_library"npm ERR! node-pre-gyp ERR! cwd C:\Users\gjaischool\Desktop\x_test\chatbot-app-master\node_modules\grpcnpm ERR! node-pre-gyp ERR! node -v v20.4.0npm ERR! node-pre-gyp ERR! node-pre-gyp -v v0.12.0npm ERR! node-pre-gyp ERR! not oknpm ERR! A complete log of this run can be found in: C:\Users\gjaischool\AppData\Local\npm-cache\_logs\2023-10-05T05_36_46_355Z-debug-0.log 이런식으로 오류가 계속납니다 .. 버전을 다운해서 받아도 나고 업그레이드 해도 나고 제발 알려주세요 ㅠㅠ
-
해결됨Slack 클론 코딩[백엔드 with NestJS + TypeORM]
socket.io 사용 시 cors 에러 with react
안녕하세요 제로초님~! 최근에 socket.io 문제를 해결해주셔서 감사합니다. 제로초님 덕분에 몇주간 있었던 불면증이 사라졌습니다. 이번에 드리고자 하는 질문은 백엔드 api 서버와 리액트 로컬호스트의 websocket 연결에서 cors 에러가 사라지지 않고 있다는 것입니다.프론트와 백엔드 둘다 localhost로 사용했을땐 문제 없이 잘 작동하였으나, 백엔드 api 서버와 프론트(리액트) http://localhost:3000 로 연결하려 하니 cors 에러가 사라지질 않네요.백엔드 api 서버주소는 https://api.yubinhome.com/ 이고, traefik 을 사용해 https 인증을 받고 있습니다.제가 어떤 부분을 놓친 것인지 함께 봐주실 수 있을까요? 에러메시지 Access to XMLHttpRequest at 'http://api.yubinhome.com/socket.io/?EIO=4&transport=polling&t=Ohzm2CT' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request. GET http://api.yubinhome.com/socket.io/?EIO=4&transport=polling&t=OhzmhTk net::ERR_FAILED 요청헤더 응답헤더 시도 해 본 방법1. 공식 문서에 나온대로 api url 에 직접 연결해보니 서버가 작동하고 있는 것은 확실해보입니다.소켓io 공식문서 cors : https://socket.io/docs/v3/handling-cors/#troubleshooting2. 서버측 origin, credetials 를 설정하였습니다. origin : "*" 가 문제인가 싶어 http://localhost:3000 url 을 직접 주었습니다. 클라이언트 측에는 withCredentials: true 을 설정해주었습니다.백엔드 api 서버 코드https://github.com/fog-of-war/dev-be/blob/dev/src/events/events.gateway.ts@WebSocketGateway({ cors: { origin: "http://localhost:3000", methods: ["GET", "POST"], allowedHeaders: ["authorization", "Authorization"], credentials: true, }, namespace: /\/ws-.+/, transports: ["websocket", "polling"], })리액트 코드https://github.com/fog-of-war/dev-fe/blob/46a8de3a13de4039e9aa511a07cfeea23d8a85fa/src/components/Notifications/NoticeNotifications.tsxREACT_APP_API_URL=https://api.yubinhome.com/REACT_APP_SOCKET_URL=ws://api.yubinhome.com/v1/ws-alertlet socket: any = null; socket = io(socketUrl + "-" + userId, { withCredentials: true, extraHeaders: { Authorization: `Bearer ${sanitizedToken}`, }, });
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
도커 컴포즈 질문드립니다
yml파일,mongo 파일,Dockerfile 만들고docker-compose builddocker-compose up 하고 다른 쉘에서docker ps했는데 아무것도 안뜹니다 파일은 제대로 따라 적었는데도 오류 뜨고 몽고 db는 삭제했고 몽고db 컴패스는 오류걸려서 그냥 삭제했습니다
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 프론트엔드 코스
27:25초에 나의그래프큐엘셋팅 파일로 이동하는방법
27:25초에 나의그래프큐엘셋팅 파일로 바로 이동해지는데 어떻게 하는걸까요
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
로그인 프로세스 설명 중 질문
해당 장을 설명해주실 때 철수가 1050번째, 영희가 2050번째라고 가정했을때, 수직 파티셔닝 된 데이터베이스 중 어디에 있는지는 미리 알 수 있는 방법이 있을까요?
-
미해결탄탄한 백엔드 NestJS, 기초부터 심화까지
프론트엔드 코드 실행시 에러가 발생합니다.
>> 갱신, 2023. 10. 06해결했습니다.https://github.com/amamov/teaching-nestjs-a-to-z/tree/frontend위 링크 설명 따라 nestjs root 디렉토리에서 git clone 받고,npm install, npm run dev 하니까 잘 실행되네요$ npm run dev > frontend@0.1.0 dev > next start ready - started server on 0.0.0.0:3000, url: http://localhost:3000 info - Loaded env from C:\Users\admin\OneDrive\바탕 화면\learning_NestJS\frontend\.env 잘못된 파일을 받았던것 같습니다..어느 질문글에서 본 링크 따라서 들어가서 받았던거로 기억하는데..어느 글이었는지 다시 찾아도 보이지 않네요.. >> 질문글, 2023. 10. 04학습자료 frontend를 다운 받았고, 이 폴더를 05 NestJS 실전 프로젝트와 같은 위치에 두었습니다.이후 프론트엔드 코드 실행 방법 강의를 보고frontend 디렉토리로 들어가 npm i를 입력하였습니다admin@DESKTOP-ALLM3V0 MINGW64 ~/OneDrive/바탕 화면/learning_NestJS/frontend (master) $ npm i npm WARN old lockfile npm WARN old lockfile The package-lock.json file was created with an old version of npm, npm WARN old lockfile so supplemental metadata must be fetched from the registry. npm WARN old lockfile npm WARN old lockfile This is a one-time fix-up, please be patient... npm WARN old lockfile npm WARN deprecated @types/antd@1.0.0: This is a stub types definition for antd (https://github.com/ant-design/ant-design). antd provides its own type definitions, so you don't need @types/antd installed! npm WARN deprecated @types/axios@0.14.0: This is a stub types definition for axios (https://github.com/mzabriskie/axios). axios provides its own type definitions, so you don't need @types/axios installed! npm WARN deprecated querystring@0.2.1: The querystring API is considered Legacy. new code should use the URLSearchParams API instead. npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead. added 368 packages, and audited 369 packages in 24s 48 packages are looking for funding run `npm fund` for details 15 vulnerabilities (3 moderate, 7 high, 5 critical) To address issues that do not require attention, run: npm audit fix To address all issues (including breaking changes), run: npm audit fix --force Run `npm audit` for details.위와 같이 경고 메세지가 나왔고... 이 상태에서 npm run dev를 입력하였더니admin@DESKTOP-ALLM3V0 MINGW64 ~/OneDrive/바탕 화면/learning_NestJS/frontend (master) $ npm run dev > frontend@0.1.0 dev > next dev ready - started server on 0.0.0.0:3000, url: http://localhost:3000 info - Loaded env from C:\Users\admin\OneDrive\바탕 화면\learning_NestJS\frontend\.env info - Using webpack 5. Reason: no next.config.js https://nextjs.org/docs/messages/webpack5 Error: error:0308010C:digital envelope routines::unsupported at new Hash (node:internal/crypto/hash:71:19) at Object.createHash (node:crypto:133:10) at BulkUpdateDecorator.hashFactory (C:\Users\admin\OneDrive\바탕 화면\learning_NestJS\frontend\node_modules\next\dist\compiled\webpack\bundle5.js:133790:18) at BulkUpdateDecorator.update (C:\Users\admin\OneDrive\바탕 화면\learning_NestJS\frontend\node_modules\next\dist\compiled\webpack\bundle5.js:133692:50) at OriginalSource.updateHash (C:\Users\admin\OneDrive\바탕 화면\learning_NestJS\frontend\node_modules\next\dist\compiled\webpack-sources2\index.js:1:19148) at NormalModule._initBuildHash (C:\Users\admin\OneDrive\바탕 화면\learning_NestJS\frontend\node_modules\next\dist\compiled\webpack\bundle5.js:65772:17) at handleParseResult (C:\Users\admin\OneDrive\바탕 화면\learning_NestJS\frontend\node_modules\next\dist\compiled\webpack\bundle5.js:65837:10) at C:\Users\admin\OneDrive\바탕 화면\learning_NestJS\frontend\node_modules\next\dist\compiled\webpack\bundle5.js:65928:4 at processResult (C:\Users\admin\OneDrive\바탕 화면\learning_NestJS\frontend\node_modules\next\dist\compiled\webpack\bundle5.js:65651:11) at C:\Users\admin\OneDrive\바탕 화면\learning_NestJS\frontend\node_modules\next\dist\compiled\webpack\bundle5.js:65711:5 Error: error:0308010C:digital envelope routines::unsupported at new Hash (node:internal/crypto/hash:71:19) at Object.createHash (node:crypto:133:10) at BulkUpdateDecorator.hashFactory (C:\Users\admin\OneDrive\바탕 화면\learning_NestJS\frontend\node_modules\next\dist\compiled\webpack\bundle5.js:133790:18) at BulkUpdateDecorator.update (C:\Users\admin\OneDrive\바탕 화면\learning_NestJS\frontend\node_modules\next\dist\compiled\webpack\bundle5.js:133692:50) at OriginalSource.updateHash (C:\Users\admin\OneDrive\바탕 화면\learning_NestJS\frontend\node_modules\next\dist\compiled\webpack-sources2\index.js:1:19148) at NormalModule._initBuildHash (C:\Users\admin\OneDrive\바탕 화면\learning_NestJS\frontend\node_modules\next\dist\compiled\webpack\bundle5.js:65772:17) at handleParseResult (C:\Users\admin\OneDrive\바탕 화면\learning_NestJS\frontend\node_modules\next\dist\compiled\webpack\bundle5.js:65837:10) at C:\Users\admin\OneDrive\바탕 화면\learning_NestJS\frontend\node_modules\next\dist\compiled\webpack\bundle5.js:65928:4 at processResult (C:\Users\admin\OneDrive\바탕 화면\learning_NestJS\frontend\node_modules\next\dist\compiled\webpack\bundle5.js:65651:11) at C:\Users\admin\OneDrive\바탕 화면\learning_NestJS\frontend\node_modules\next\dist\compiled\webpack\bundle5.js:65711:5 node:internal/crypto/hash:71 this[kHandle] = new _Hash(algorithm, xofLen); ^ Error: error:0308010C:digital envelope routines::unsupported at new Hash (node:internal/crypto/hash:71:19) at Object.createHash (node:crypto:133:10) at BulkUpdateDecorator.hashFactory (C:\Users\admin\OneDrive\바탕 화면\learning_NestJS\frontend\node_modules\next\dist\compiled\webpack\bundle5.js:133790:18) at BulkUpdateDecorator.update (C:\Users\admin\OneDrive\바탕 화면\learning_NestJS\frontend\node_modules\next\dist\compiled\webpack\bundle5.js:133692:50) at OriginalSource.updateHash (C:\Users\admin\OneDrive\바탕 화면\learning_NestJS\frontend\node_modules\next\dist\compiled\webpack-sources2\index.js:1:19148) at NormalModule._initBuildHash (C:\Users\admin\OneDrive\바탕 화면\learning_NestJS\frontend\node_modules\next\dist\compiled\webpack\bundle5.js:65772:17) at handleParseResult (C:\Users\admin\OneDrive\바탕 화면\learning_NestJS\frontend\node_modules\next\dist\compiled\webpack\bundle5.js:65837:10) at C:\Users\admin\OneDrive\바탕 화면\learning_NestJS\frontend\node_modules\next\dist\compiled\webpack\bundle5.js:65928:4 at processResult (C:\Users\admin\OneDrive\바탕 화면\learning_NestJS\frontend\node_modules\next\dist\compiled\webpack\bundle5.js:65651:11) at C:\Users\admin\OneDrive\바탕 화면\learning_NestJS\frontend\node_modules\next\dist\compiled\webpack\bundle5.js:65711:5 { opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ], library: 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED' } Node.js v18.16.0위와 같은 에러가 발생하며 프론트엔드가 웹 서버가 실행되지 않고 있습니다..이러한 상황에서는 어떻게 진행하면 좋을지 조언 부탁드립니다.
-
미해결Node.js에 TypeScript 적용하기(feat. NodeBird)
'S3' 형식에 'S3Client' 형식의 destroy, middlewareStack, send 속성이 없습니다.ts(2739)
안녕하세요 선생님user, post 라우터 편을 보면서 코드를 작성하던중 에러가 발생해서 문의드립니다. AWS S3 업로드 관련 부분인데 AWS.config.update({ region: 'ap-northeast-2', accessKeyId: process.env.S3_ACCESS_KEY_ID, secretAccessKey: process.env.S3_SECRET_ACCESS_KEY, }); const upload = multer({ storage: multerS3({ s3: new AWS.S3(), // s3 이부분에서 에러가 발생합니다 bucket: 'react-nodebird', key(req, file, cb) { cb(null, `original/${+new Date()}${path.basename(file.originalname)}`); }, }), limits: { fileSize: 20 * 1024 * 1024 }, }); 'S3' 형식에 'S3Client' 형식의 destroy, middlewareStack, send 속성이 없습니다.ts(2739) (property) Options.s3: S3Client 빠른 수정을 사용할 수 없음 위와 같은 에러가 발생했습니다. 그래서 구글링을 통해 에러를 수정한 코드가 아래와 같은데 이 부분이 올바르게 작성된건지 확인부탁드리고자 질문남깁니다. const upload = multer({ storage: multerS3({ s3: new S3Client({ credentials: { accessKeyId: process.env.S3_ACCESS_KEY as string, secretAccessKey: process.env.S3_SECRET_KEY as string, }, region: 'ap-northeast-2', }), bucket: 'react-nodebird', key(req, file, cb) { cb(null, `original/${+new Date()}${path.basename(file.originalname)}`); }, }), limits: { fileSize: 20 * 1024 * 1024 }, });
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
productsSalesLocation.service create method
create({productSalesLocation}): Promise<ProductSalesLocation>{ return this.productsSalesLocationsRepository.save({...productSalesLocation}); }강의 중 위와 같은 코드를 작성해주셨는데, create의 parameter type은 ProductSalesLocation(Entity)의 타입에서 id만 제외하고 사용하는 형태로 작성하는 것이 맞을까요?