inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

173만명의 커뮤니티!! 함께 토론해봐요.

[질문X] 로컬에서 build 후 npm start 에러

미해결

Next + React Query로 SNS 서비스 만들기

[auth][error] UntrustedHost: Host must be trusted. URL was: http://localhost:3000/api/auth/session .Read more at https://errors.authjs.dev#untrustedhost 백엔드를 로컬에서 돌리고 Next를 build 후 npm start 로 서버를 돌렸을 경우 발생하는 Next-Auth.js(Auth.js) 에러입니다. 신뢰되지 않은 호스트라 발생하는 에러라고 해서 찾아봤습니다. 방법 1. AUTH_TRUST_HOST=http://localhost:3000 .env 파일에 AUTH_TRUST_HOST 추가하기 [참고] https://github.com/nextauthjs/next-auth/discussions/6071 방법 2. export const { handlers: { GET, POST }, auth, signIn, } = NextAuth({ trustHost: true, // ... src\auth.ts 파일에 NextAuth 옵션에서 trustHost: true 옵션 추가하기 [참고] https://github.com/nextauthjs/next-auth/issues/6113

  • react
  • next.js
  • react-query
  • next-auth
  • msw
이우열 댓글 1 좋아요 8 조회수 1144

mocks 폴더 파일 별 내용 정리 혹시 제대로 이해한건가요?ㅜ

해결됨

Next + React Query로 SNS 서비스 만들기

Next 프로젝트는 클라이언트에서도 동작하고 서버에서도 동작한다. 그래서 MSW가 클라이언트, 서버에서 동작해야한다. 그러나 아직 서버에서 MSX를 실행하는 방식이 아직 나오지 않았다. 그래서 우리는 임시로 노드 서버를 사용한다. browser.ts - 클라이언트에서 API 요청 모킹 처리해주는 파일 -> 클라이언트 컴포넌트에서 API 요청 시 처리? http.ts - 서버에서 API 요청 모킹 처리해주는 파일 (노드 서버 사용) -> 서버 컴포넌트에서 API 요청시 처리? handlers.ts - 실제 API 모킹 코드

  • react
  • next.js
  • react-query
  • next-auth
  • msw
욱둥이 댓글 1 좋아요 1 조회수 470

className 자동완성 질문

미해결

Next + React Query로 SNS 서비스 만들기

className 자동완성으로 중괄호 { }로 설정하려면 어떻게 해야하나요? 설정에서 ', "으로 변경하는 건 찾았는데 중괄호는 못찾아서 질문남깁니다!

  • react
  • next.js
  • react-query
  • next-auth
  • msw
홍시 댓글 2 좋아요 0 조회수 547

refreshToken useAuth에 적용했을 때 문제점

미해결

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

안녕하세요. 리프레쉬 토큰을 사용하여 useAuth에 적용을 했는데요. 로그인을 하여 리프레쉬 토큰이 발급 되어도 조건에 만족하지 못하고 있습니다. 확인해보니 restoreAccessToken을 가져오지 못하여 발생하는 이벤트 였습니다. 하지만 새로고침을 하면 리프레시 토큰을 찾아서 인증이 됩니다. 무슨 이유 때문인지 잘 모르겠습니다. 리프레시 토큰 코드도 첨부하도록 하겠습니다. 추가적으로 로그인 인증시 getAccessToken을 직접 불러오면 문제가 없지만 리코일로더블로 이용하면 이런 문제가 생깁니다.!!

  • react
  • node.js
  • seo
  • graphql
  • next.js
김태연 댓글 1 좋아요 0 조회수 351

로그아웃 시 router cache 갱신 안됨

미해결

Next + React Query로 SNS 서비스 만들기

signOut({ redirect: false }).then(() => { fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/api/logout`, { method: "post", credentials: "include", }); router.refresh(); router.replace("/"); }); 로그아웃 버튼에 `router.refresh()`를 추가하면 로그아웃 버튼을 누르고 다시 로그인했을 때 기존 정보의 캐시가 삭제되고 새로 갱신된다고 하셨는데 저 코드를 추가해도 기존 정보가 계속 남아있는 경우는 어디를 확인해봐야 할까요? 브라우저에서 캐시 지우고 새로고침, 브라우저 창 재시작, 서버 껐다 켜기를 해봤는데도 계속 이전 정보가 남아있습니다..

  • react
  • next.js
  • react-query
  • next-auth
  • msw
이우열 댓글 3 좋아요 0 조회수 494

플러그인이 추천을 안해줍니다

미해결

따라하며 배우는 리액트 A-Z[19버전 반영]

예전 질문글처럼처음부터 다시 설치해봐도 해결이 안되어 질문을 올립니다.

  • react
  • redux
  • tdd
  • typescript
  • next.js
  • 소프트웨어-테스트
오징어 댓글 1 좋아요 0 조회수 354

프리캠프 회원가입

해결됨

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

<!DOCTYPE html> <html lang="ko"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <link rel="stylesheet" href="./css/index.css"> </head> <body> <div class="wrapper"> <div class="main"> <div class="detail"> <div class="detail1">회원가입을 위해<br> 정보를 입력해주세요</div> <div class="detail2"> <input type="text" class="box" placeholder="* 이메일"> </div> <div class="detail3"> <input type="text" class="box" placeholder="* 이름"> </div> <div class="detail4"> <input type="password" class="box" placeholder="* 비밀번호"> </div> <div class="detail5"> <input type="password" class="box" placeholder="* 비밀번호 확인"> </div> <div class="gender"> <div> <input type="radio" name="gender">여성 </div> <div> <input type="radio" name="gender">남성 </div> </div> <div class="checkbox"> <input type="checkbox">이용약관 개인정보 수집 및, 마케팅 활용 선택에 모두 동의합니다. </div> <div class="line"></div> <div class="join"> <button>가입하기</button> </div> </div> </div> </div> </div> </body> </html> * { box-sizing: border-box; margin: 0px; } html,body { width: 100%; height: 100%; } .wrapper { width: 1920px; height: 1080px; display: flex; flex-direction: row; align-items: center; justify-content: center; } .main { width: 670px; height: 960px; border-radius: 20px; border: 1px solid #AACDFF; display: flex; flex-direction: row; align-items: center; justify-content: center; box-shadow: 7px 7px 39px 0px #0068FF40; } .detail { width: 470px; height: 818px; display: flex; flex-direction: column; align-items: center; } .detail1 { width: 466px; height: 94px; font: 700; font-size: 32px; color: #0068FF; } .detail2 { width: 466px; height: 80px; color: #797979; border-bottom: 1px solid #0068FF; } .detail3 { width: 466px; height: 80px; color: #797979; border-bottom: 1px solid #797979; } .detail4 { width: 466px; height: 80px; color: #797979; border-bottom: 1px solid #797979; } .detail5 { width: 466px; height: 80px; color: #797979; border-bottom: 1px solid #797979; margin-bottom: 20px; } .box { border: none; padding-top: 30px; } .gender { width: 140px; height: 23.94px; border: none; display: flex; flex-direction: row; justify-content: space-between; margin: 20px; } .checkbox { width: 454px; height: 21.06px; display: flex; flex-direction: row; justify-content: center;; font-size: 15px; margin: 30px; } .line { width: 470px; height: 1px; color: #E6E6E6; border: 1px solid #E6E6E6; margin: 20px; } .join { width: 470px; height: 75px; border: 1px solid #0068FF; border-radius: 10px; display: flex; justify-content: center; margin: 20px; } button { border: none; background-color: white; color: #0068FF; } 생긴건 비슷하게 만들었는데 가입하기가 안 눌리는 것 같아요ㅠㅠ 이메일,이름 등 인풋도 밑줄에 맞게 써지지도 않습니다 ㅠㅠ

  • react
  • node.js
  • seo
  • graphql
  • next.js
이승헌 댓글 2 좋아요 0 조회수 266

회원가입 리다이렉트 오류

미해결

Next + React Query로 SNS 서비스 만들기

현재 상태는 201로 불러와도 redirect가 되지 않습니다. console.log()로 찍어보니 await signIn 이후로는 console.log()가 찍히지가 않았습니다. axios로 바꿔봐도 그대로이고 버전도 @auth/core 버전도 바꿔보았는데 꿈쩍 않습니다 ㅠ 물론 DB에도 정상적으로 데이터가 저장되고요.. 시간만 날리다가 도저히 안되겠기에 질문 남깁니다.. signup.ts "use server"; import { signIn } from "@/auth"; import { redirect } from "next/navigation"; // import axios from "axios"; export default async (prevState: any,formData: FormData) => { // 입력값이 없거나 || 빈칸이 존재하지않을때 if (!formData.get("id") || !(formData.get("id") as string)?.trim()) { return { message: "no_id" }; } if (!formData.get("name") || !(formData.get("name") as string)?.trim()) { return { message: "no_name" }; } if (!formData.get("password") || !(formData.get("password") as string)?.trim()) { return { message: "no_password" }; } if (!formData.get("image")) { return { message: "no_image" }; } formData.set("nickname", formData.get("name") as string); let shouldRedirect = false; try { const response = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/api/users`,{ method : 'post', body: formData, credentials: "include", // 쿠기 전달 가능캐 함 }); console.log("회원가입상태 : ",response.status); // 회원가입시 이미 가입되어있을때 if (response.status === 403) { return { message: "user_exists" }; } shouldRedirect = true; await signIn("credentials", { username: formData.get('id'), password: formData.get('password'), redirect: false, }) } catch (err) { console.error(err); return {message : null}; } console.log("11") if (shouldRedirect) { console.log("리다이랙트"); redirect("/home"); } return { message: null}; };

  • react
  • next.js
  • react-query
  • next-auth
  • msw
Jinhye Kim 댓글 2 좋아요 0 조회수 448

auth 쓸때 name 외 정보들은 확인이 안되네요

미해결

Next + React Query로 SNS 서비스 만들기

https://github.com/nextauthjs/next-auth/discussions/10399#discussion-6417675 next-auth 쪽에도 help 쪽에 질의를 해놨는데요, 원래 이슈로 쓰려했는데 reproduce url을 요구하더라구요 ㅠㅠ 현재 auth는 이슈가 적다고 하신 라이브러리를 쓰고있어요 "@auth/core": "^0.27.0", "next": "14.0.4", "next-auth": "^5.0.0-beta.11", 를 사용중이고요, custom login 페이지를 두었는데 credentials 정보는 잘 넘어와서 login api 도 잘 타는데 그 내용을 토대로 클라이언트에서 useSession으로 유저 정보를 확인하려해도 name 만 정상적으로 리턴이되네요.. import NextAuth from "next-auth"; import CredentialsProvider from "next-auth/providers/credentials"; import { NextResponse } from "next/server"; export const { handlers: { GET, POST }, auth, signIn, } = NextAuth({ pages: { signIn: "/login", }, providers: [ CredentialsProvider({ async authorize(credentials) { console.log( "credentials info: " + credentials.email + " " + credentials.password ); const params = new URLSearchParams( `empNo=${credentials.email}&empPassword=${credentials.password}` ); console.log(params); const authResponse = await fetch( `http://?????:9080/api/getempinfo`, { method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded", }, body: params, } ); if (!authResponse.ok) { return null; } const user = await authResponse.json(); console.log("user", user); // user.retData[0] inside informations are all string. // { // user_id: '*******', // user_name: 'jinyoung', // sert_num: '*********', // user_rgst_patr_code: '001', // rdp_code: '000' // } console.log("user.retdata.user_id =", user.retData[0].user_id); console.log( "user.retdata.user_name=", user.retData[0].user_name ); const id = user.retData[0].user_id; return { // mapping info // id?: string // name?: string | null // email?: string | null // image?: string | null id: id, name: user.retData[0].user_name, ...user.retData[0], }; }, }), ], // secret: , trustHost: true, }); 아래는 useSession 을 사용하는 클라이언트 컴포넌트에요 "use client"; import React, { useEffect, useState } from "react"; ... // import useSWR from "swr"; import { useSession } from "next-auth/react"; ... const Home = () => { const { data: session, status } = useSession(); console.log("status?"); console.log("status=" + status); console.log("session="); console.log(session?.user); useEffect(() => { if (session) { console.log("session useEffected = "); console.log(session); } }, [session]); 아래는 콘솔 찍어본 내용이에요

  • next.js
  • next-auth
danroom85 댓글 2 좋아요 0 조회수 323

넥스트에서 로그인 분기처리 질문

미해결

Next + React Query로 SNS 서비스 만들기

넥스트에서 로그인시 해당유저의 role에 따라 분기를 나눌려면 어떠한 방식을 사용해야할까요? 로그인된 유저의 role은 student, teacher, admin 세가지의 값이 있으며 유저는 유저페이지만 선생은 선생페이지만 어드민은 어드민페이지만 따로 보여주는 방식이 있나요? 폴더구조는 이러합니다. (afterLogin) - (admin) - (teacher) - (student) (beforeLogin) - ...

  • react
  • next.js
  • react-query
  • next-auth
  • msw
무지55 댓글 1 좋아요 0 조회수 277

컴포넌트 props 질문

해결됨

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

자잘하게 궁금한게 있으면 여러방식으로 직접해보고는 하는데요 아래의 코드처럼 {...["a", "b", "c"]} 이렇게 props를 전달했을 때 console에는 {0: "a", 1: "b", 2: "c"} 이렇게 없던 배열값의 키값이 생겼습니다. 짐작하기로는 index 위치가 key값이 된 것 같기는 한데 왜 이렇게 되는지 궁금합니다. ex) parent/index.tsx import Child from "./child/index.tsx"; export default function Parent(): JSX.Element { return <Child {...["a", "b", "c"]} />; } ex) parent/child/index.tsx export default function Child(props: any): JSX.Element { console.log(props); // {0: "a", 1: "b", 2: "c"} return <></>; }

  • react
  • next.js
joka 댓글 1 좋아요 0 조회수 177

DB에서 Comment 테이블이 안불러와지는 것 같습니다.

해결됨

[리뉴얼] React로 NodeBird SNS 만들기

// posts.js router.get("/", async (req, res, next) => { // GET /posts console.log(Comment); try { const posts = await Post.findAll({ limit: 10, order: [["createdAt", "DESC"]], include: [ { model: User, attributes: ["id", "nickname"], }, { model: Image, }, { model: Comment, include: [ { model: User, attributes: ["id", "nickname"], }, ], }, ], }); res.status(200).json(posts); } catch (error) { console.error(error); next(error); } }); module.exports = router; LOAD_POST_REQUEST 액션이 dispatch돼서 api 요청을 통해 data를 받아오면 data안에 Comments의 값이 Comments 테이블에 들어있는 값이 들어있을 것으로 예상이 되는데 빈배열인 상황입니다. 혹시 다른 살펴볼만한 곳이 있는지 알려주시면 감사하겠습니다. 감사합니다.

  • react
  • redux
  • node.js
  • express
  • next.js
쾌할한 전복 댓글 2 좋아요 0 조회수 285

[react-query] queryClient.prefetchQuery 사용목적 구분이 헷갈립니다.

미해결

Next + React Query로 SNS 서비스 만들기

message페이지 수정하기편에서 queryClient.prefetchQuery를 사용했는데 다른 컴포넌트에서 queryClient. prefetchQuery를 사용할때는 HydrationBoundary컴포넌트로 감싸고 state에 fetching 해온 데이터를 주입시켜서 사용했는데 여기서는 왜 아무곳에서도 사용하고 있지 않은건지 궁금합니다. 그리고 HydrationBoundary컴포넌트로 감싸고 state에 fetching해온 데이터를 주입시켜서 사용하고 있는곳들도 자식 컴포넌트에서 또 useQuery를 사용하는데 부모 HydrationBoundary에 접근해서 데이터를 사용하지 않고 useQuery로 fetching해와서 사용하는건지 궁금합니다. 저는 여태 HydrationBoundary가 fetching해온 데이터를 공유해주는 ContextAPI같은 컴포넌트라고 생각했었습니다. 자식컴포넌트에서 일일이 useQuery로 데이터를 가져오는거면 상위에 HydrationBoundary컴포넌트 안만들어줘도 되는거 아닌가요?

  • react
  • next.js
  • react-query
  • next-auth
  • msw
라푼젤 댓글 1 좋아요 0 조회수 582

DB연결

미해결

Next + React Query로 SNS 서비스 만들기

msw에서 DB를 연결해서 사용하고싶습니다.몽고디비를 연결하고싶은데 타입스크립트를 잘 몰라서 연결을 못하겠습니다 ... 구글 찾아봐도 잘 안나오는데 혹시 방법이 있을까요 ?

  • react
  • next.js
  • react-query
  • next-auth
  • msw
박진섭 댓글 1 좋아요 0 조회수 286

react-infinite-scroller에 overflow style 사용하기

미해결

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

안녕하세요. 중고마켓 리스트를 무한스크롤로 구현 중에 있는데요. 부모 요소를 감싸서 overflow로 스크롤을 주면 height값이 먹혀서 데이터를 20개 가져오고 나서는 더이상 스크롤을 내릴 수가 없네요. 이건 ListWrap인 스크롤 컴포넌트의 부모요소를 없앨때 이구요. 이건 ListWrap을 넣었을 때 저렇게 값이 나옵니다. 어떻게 해야할까요? 아니면 무한스크롤은 아래처럼 overflowscroll을 넣고 구현이 안되는건가요?

  • react
  • node.js
  • seo
  • graphql
  • next.js
댓글 1 좋아요 0 조회수 414

react-query와 nextjs에서 둘 다 cache 처리 해주는 건가요?

미해결

Next + React Query로 SNS 서비스 만들기

next: { tags: {'posts', id} } nextjs에서의 위의 코드는 nextjs의 캐시를 하는거라면 nextjs는 서버캐시를 하고 react-query는 클라이언트 캐시를 해주는건가요? 둘 다 중복적으로 캐시를 지원해주거 맞죠? 헷갈리네요

  • react
  • next.js
  • react-query
  • next-auth
  • msw
라푼젤 댓글 1 좋아요 0 조회수 456

ubuntu안에 있는 mysql db데이터

해결됨

[리뉴얼] React로 NodeBird SNS 만들기

안녕하세요 제로초님, 로컬상에서 mysql workbench 처럼 ec2인스턴스 ubuntu내에 있는 mysql db 데이터들을 시각화해서 관리할 수 있는 툴 같은 건 혹시 없을까요? 데이터들을 수정하고 싶을때 query문으로 직접 관리하는 것이 일반적인지 문의드립니다!

  • react
  • redux
  • node.js
  • express
  • next.js
do wang 댓글 1 좋아요 0 조회수 207

자바스크립트 배열 email split 콘솔 내용 복사 후 주석처리

해결됨

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

안녕하세요 자바스크립트 배열 중에 email split 따라하면서 콘솔에 있는 내용 복사해서 vb Code에 붙혀 넣고 주석처리 했습니다. 근데 주석 뒤에 "codecamp": Unknown word. 라고 나타납니다. 이건 왜 그런가요?

  • react
  • node.js
  • seo
  • graphql
  • next.js
베이직 댓글 2 좋아요 0 조회수 218

error.tsx를 활용한 에러 처리 관련 질문입니다.

해결됨

Next + React Query로 SNS 서비스 만들기

안녕하세요 해당 영상을 통해 학습하고 따로 프로젝트를 진행하는 중에 서버 컴포넌트에서 data를 fetch하고 api 상태코드에 따라서 next에서 제공하는 error.tsx에서 해당 에러 상태에 따라 모달에 메세지를 띄우는 작업을 하고 있습니다. 로컬 환경에서 실행시켰을때는 정상적으로 error status가 523이 발생했을때 정상적인 메세지를 받아서 error.tsx 화면에서 해당 에러 메세지를 모달에 띄우나 빌드 후 실행시켰을 때에는 An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error. 모달안의 메세지에 이러한 문구가 뜹니다. 아무리 찾아봐도 정확한 원인을 모르겠는데 혹시 해결방법을 아실까요? 다국어 처리 라이브러리는 next-intl를 사용하였습니다. /note/page.tsx async function fetchSharedNote(guid: string) { try { const res = await fetch( `${process.env.API_SERVER_URL}/v1/...`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(guid), } ); if (res.ok) { return res.json(); } else { const errorData = await res.json(); throw errorData; } } catch (err: any) { const t = await getTranslations("Index"); if (err.status === RestApiErrorType.notExistResourceException) { throw new Error(t("error523")); } throw new Error(err.message); } } /note/error.tsx "use client"; // Error components must be Client Components import CommonDialog from "@/app/_components/CommonDialog/index"; import { useState } from "react"; export default function Error({ error, }: { error: Error & { digest?: string }; reset: () => void; }) { const [showDialog, setShowDialog] = useState(!!error.message); return ( <CommonDialog isShow={showDialog} contents={error.message} onClick={() => { setShowDialog(false); }} /> ); }

  • react
  • next.js
  • react-query
  • next-auth
  • msw
박지수 Jisu Park 댓글 1 좋아요 0 조회수 883

git push -> git pull 후에 build 문의

해결됨

[리뉴얼] React로 NodeBird SNS 만들기

안녕하세요~ backUrl을 수정하여 소스코드가 변동되었으니 github에 commit push를 한 뒤, 우분투 서버에 접속하여 front에서 다시 git pull을 할 경우, 우분투 서버 front에서 build를 또 진행 해야하나요? 그리고, 이전에 강의에서 vim으로 .env를 만든것들도 다시 만들어야할까요?

  • react
  • redux
  • node.js
  • express
  • next.js
hyuri 댓글 1 좋아요 0 조회수 223

인기 태그

인프런 TOP Writers

주간 인기글