안녕하세요 제로초님! 강의 잘 듣고 있습니다. 화면이 mount 되었을 때는 최상단에 존재하는 page.tsx에 의해 localhost:3000 URL가 나오고 있는 상황입니다. 그런데 처음 mount 되었을 때 localhost:3000/login 형태의 URL을 가지려고 한다면 어떤 방법으로 해야할지 궁금합니다! 제가 생각한 방법은 아래와 같은데 좀 더 좋은 방법이 있을까요? 1. 최상단에 존재하는 page.tsx에서 useEffect 내부에 router.push('/login') 을 한다. next 에서 제공하는 redirect 기능을 사용한다.
안녕하세요. 강의와는 무관한 질문이지만 본 강의 수강 완료 후 혼자서 프로젝트를 하고 있습니다. 현재 구글 리뷰 크롤링 & 스크랩중인데요. 해당 에러가 발생하는 이유를 도무지 찾을 수 가 없어서 질문 드립니다... 여러 사이트를 크롤링 해보고 엑셀을 생성 해 보았지만 왜 이런 에러가 발생하는지 로그를 봐도 제대로 표시가 안되니깐 찾기가 힘드네요. 구글 리뷰 사이트만 20여개 스크랩 했었고 엑셀도 제대로 생성 되었으니 스크랩 코드 자체에는 문제가 없는거 같습니다. 다만 이 부분에서만 문제가 생깁니다. ### 에러 발생 로그 [2024-06-12 09:42:59,954] [ERROR utils.py:179] >> Traceback (most recent call last): File "scraper\scrap_crawlers.py", line 1365, in get_review_details File "scraper\utils.py", line 202, in create_xlsx_file File "scraper\utils.py", line 181, in create_xlsx_file File "pandas\util\_decorators.py", line 333, in wrapper File "pandas\core\generic.py", line 2417, in to_excel File "pandas\io\formats\excel.py", line 952, in write File "pandas\io\excel\_openpyxl.py", line 490, in write cells File "openpyxl\cell\cell.py", line 218, in value File "openpyxl\cell\cell.py", line 197, in bind value File "openpyxl\cell\cell.py", line 165, in check_string openpyxl.utils.exceptions.IllegalCharacterError: 동생한테추천받았는데이렇게편한어플이있다니너무좋아요.현금비율은좋지않지만 신경많이안써도되서괜찮네요~ cannot be used in worksheets. During handling of the above exception, another exception occurred: ### cannot be used in worksheets. 이놈이 말썽이네요... 아래와 같이 테스트 케이스 만들어서 적용했을 때는 제대로 작동했었습니다. import asyncio from scraper.utils import create_xlsx_file, save_to_xlsx DEFAULT_NAME = "test" async def main(): data = { "message": "동생한테추천받았는데이렇게편한어플이있다니너무좋아요.현금비율은좋지않지만 신경많이안써도되서괜찮네요~" } xlsx_file = await create_xlsx_file( data, file_name=DEFAULT_NAME, sheet_name=DEFAULT_NAME ) await save_to_xlsx(xlsx_file, DEFAULT_NAME) asyncio.run(main()) # utils.py # 엑셀 가로 폭 조정하는 함수 async def calculate_dimension(worksheet: Worksheet) -> None: try: for column_cells in worksheet.iter_cols(): length = max(len(str(cell.value)) for cell in column_cells) adjusted_width = (length + 2) * 1.2 # 조정된 폭 계산 column_letter = get_column_letter(column_cells[0].column) worksheet.column_dimensions[column_letter].width = adjusted_width except Exception as e: message = f"엑셀 폭 조정 중에 예외 발생: '\n{e}" logger = await get_logger() logger.error(message) print(message) raise e # 엑셀에 서식 스타일 지정하는 함수 async def cell_pattern_fill( df: pd.DataFrame, worksheet: Worksheet, head_fill_color: str = "4472C4", head_font_color: str = "FFFFFF", body_fill_color: str = "D9E1F2", body_font_color: str = "000000", head_border_color: str = "2E5C99", body_border_color: str = "B4C6E7", fill_type: fills = "solid", ) -> None: try: # Define border styles thin_border_head = Border( left=Side(border_style="thin", color=head_border_color), right=Side(border_style="thin", color=head_border_color), top=Side(border_style="thin", color=head_border_color), bottom=Side(border_style="thin", color=head_border_color), ) thin_border_body = Border( left=Side(border_style="thin", color=body_border_color), right=Side(border_style="thin", color=body_border_color), top=Side(border_style="thin", color=body_border_color), bottom=Side(border_style="thin", color=body_border_color), ) # Set header row style for row in worksheet.iter_rows( min_row=1, max_row=1, min_col=1, max_col=df.shape[1] ): for cell in row: cell.fill = PatternFill( start_color=head_fill_color, end_color=head_fill_color, fill_type=fill_type, ) cell.font = Font(color=head_font_color, bold=True) cell.border = thin_border_head # Set body row style for i, row in enumerate( worksheet.iter_rows( min_row=2, max_row=worksheet.max_row, min_col=1, max_col=df.shape[1] ) ): for cell in row: if i % 2 == 0: cell.fill = PatternFill( start_color=body_fill_color, end_color=body_fill_color, fill_type=fill_type, ) cell.font = Font(color=body_font_color) cell.border = thin_border_body except Exception as e: message = f"엑셀 서식 지정 중에 예외 발생: '\n{e}" logger = await get_logger() logger.error(message) print(message) raise e # 본 강의 drf 엑셀 생성 파트를 참고해서 만든 엑셀 생성 함수 async def create_xlsx_file( data: Union[Dict, List], file_name: str = DEFAULT_DIR_NAME, sheet_name: str = DEFAULT_DIR_NAME, ) -> BytesIO: df = pd.json_normalize(data) io = BytesIO() io.name = file_name try: writer = pd.ExcelWriter(io, engine="openpyxl") # noqa df.to_excel( writer, index=False, engine="openpyxl", sheet_name=sheet_name, ) workbook = writer.book worksheet = workbook.active tasks = [ calculate_dimension(worksheet), cell_pattern_fill(df, worksheet), ] await tqdm.gather(*tasks, desc=f" 엑셀 파일 생성중") writer._save() # noqa except Exception as e: message = f"엑셀 생성 중에 예외 발생: '\n{e}" logger = await get_logger() logger.error(message) print(message) raise e io.seek(0) return io # 엑셀 저장 함수 async def save_to_xlsx( xlsx_file: BytesIO, dirname: str = DEFAULT_DIR_NAME, ): output_path = BASE_DIR / "스크랩_결과" / "엑셀" / dirname output_path.mkdir(parents=True, exist_ok=True) now = datetime.datetime.now() timestamp = now.strftime("%Y-%m-%d_%H_%M") filename = f"{xlsx_file.name}_{timestamp}" extension = ".xlsx" file_path = output_path / (filename + extension) try: async with aiofiles.open(file_path, "wb") as f: await f.write(xlsx_file.getvalue()) except Exception as e: message = f"엑셀 파일 저장 중에 예외 발생: '{filename}'\n{e}" logger = await get_logger() logger.error(message) print(message) raise e 전체적인 함수는 위와 같으며 엑셀 생성 중에 에러가 발생하였으니 create_xlsx_file 함수 부분에서 해결을 해보아야 할것 같습니다. 아니면 혹시 엑셀의 행을 생성 중에 에러가 발생하였을 때 해당 행은 스킵하고 이어서 진행하게 하는 방법이 있을까요?? "raise e"을 발생 시키지 않아도 엑셀 생성 작업 스킵이 되지않고 작업 자체에 문제가 생기네요
onChangeContents 함수 부분에 넣었을때 처음엔 버튼이 노란색으로 변했습니다만 이후 onChangeWriter 와 onChangeTItle 부분까지 넣은 후 버튼의 색이 변하지 않습니다. if문을 다 지우고 setIsActive(true)만 넣었을때는 작동이 됩니다..
button onClick () => moveToList() 호출 시 파라미터가 없기 때문에 if 절 타지 않고(undefined) else로 빠지는데, 동작이 잘 되는 이유는 moveToList() 함수 밖에서 선언한 const queryDefault = createSearchParams({ page, size }).toString(); 덕분에 동작이 잘 되는것입니다.
안녕하세요 우선 강의 열심히 잘 보고 있습니다. 다른게 아니라 리액트와 next.js 수업이 조금 헷갈리는데 섹션5부분만 리액트이고 그 뒤에는 next.js라고 보면 되나요? 강의를 보다가 어느순간 제가 알고있는 리액트의 폴더구조들이 조금 다르더라구요. 리액트에서는 폴더중에 App.js인데 _app.js 이런식으로 되어있고 또 마지막 포트폴리오 리뷰에서는 화면에 리액트 로고부분도 나와있어서 어디서부터 어디까지가 리액트이고 next.js 강의인지 알려주시면 너무 감사드리겠습니다 ^^ 마지막으로 포트폴리오 리뷰는 제가 어떠한걸 보고 만든 후 보는 영상인지 아니면 그냥 영상을 보고 같이 하는건지도 알고싶습니다.
수업을 듣다가 궁금한 점이 생겨 문의 드립니다. 현재 React를 사용하여 API 서버와 작업할 때는 JWT 토큰을 자주 사용하는데, 타임리프(Thymeleaf)와 같은 서버 사이드 렌더링을 사용할 때도 JWT 토큰을 사용해도 되는지, 혹은 사용하면 안 되는지 궁금합니다!
포트폴리오를 만드는중에 refreshToken을 이용해서 로그인 데이터를 저장한 후에 생긴 문제입니다. 게시글 조회 페이지에서 새로고침을 하면 fetchBoards와 fetchBoardCount 요청이 2번씩 나가고 뒤에오는 요청은 canceled 되는데 이런 경우는 어떤거 때문에 생기는건지 궁금합니다. localStorage로 되돌리면 다시 오류없이 잘 동작합니다 refreshToken을 사용하고 저 오류가 생기면 게시글 등록후에 간헐적으로 새로고침을 해야 refetch되는거 같습니다.
현재 vercel에 정상 배포한 후 확인해보았는데 src/pages/Diary.jsx 에 존재하는 if (!curDiaryItem) { return <div>데이터 로딩중...</div>; } 이렇게 설정한 부분만 보이고 기존에 보여져야 할 것들이 모두 안보이는데 이유를 모르겠습니다 ㅠ 그리고 <meta property="op:image" content="/thumbnail.png" /> 로 지정해주었는데 왜 이것만 잘 안되는지 모르겠습니다.. 현재 vercel 주소입니다. https://emotion-diary-sable-theta.vercel.app/ github repo주소입니다. https://github.com/jjacksang/one-bite-react-v2
지금 제로초님은 벡엔드와 프론트서버를 구분해두셨고 백엔드서버는 ec2에 올리지않아서 백엔드와 관련된 것들은 작동하지 않는 상태인데, 만약에 fetch할때 백엔드서버주소가 아닌 프론트쪽 경로로 해서 하면 본 강좌에서 한것과 같이 ec2로 배포를 해도 작동을 할까요? 아니면 이경우 배포방법이 달라지나요?
안녕하세요! 강의와 직접적으로 관련된 질문은 아니지만 도저히 해결책을 도저히 찾기가 어려워서 질문 글 올립니다.. 하나의 Next.js 프로젝트에서 백엔드 api를 구성할 때, node.js와 파이썬 서버리스 함수를 함께 사용할 수 있나요? 백엔드로 파이썬 서버리스 함수를 단독으로 사용하는 것은 가능한 것 같은데, 동일한 프로젝트에서 node.js 서버리스 함수와 함께 사용할 수 있는지가 궁금합니다..