Posts
Q&A
post, put, delete ํ ๋ data ๋ณด๋ด๋ ์ด์ ?
์ํ ๊ทธ๊ฒ ํต์ฌ์ด๋ค์ ๊ฐ์ฌํฉ๋๋ค
- 0
- 3
- 416
Q&A
post, put, delete ํ ๋ data ๋ณด๋ด๋ ์ด์ ?
๋ ธ๋๋ฒ๋ ํ๋ก์ ํธ์์๋ ํ๋ก ํธ์์ ์ ๋ฐ์ดํธ๋ฅผ ์ผ๋จ ํ ๊ฒ ์๋๊ณ , db ๋ณ๊ฒฝ ํ์ ์๋ฒ์์ ๋ฐ์ response๋ฅผ ํ๋ก ํธ์ ์ ๋ฐ์ดํธ ์ํค๋ ๊ฑฐ ์๋๊ฐ์?? ๊ทธ๋์ ํ๋ก ํธ์์ ๋น๋๊ธฐ ์ฒ๋ฆฌ ํ์ success ๋๋ failure๋ก ๋์ด๊ฐ๋ ๊ฒ ์๋๊ฐ์? ์ํ ์๋น์ค์ ๋ง๊ฒ ์์ ๋กญ๊ฒ ํ๋ฉด ๋๋ ๊ฑฐ๊ตฐ์ ๊ฐ์ฌํฉ๋๋ค!
- 0
- 3
- 416
Q&A
Application > Cookies ์ front์๋ง ์ ์ฅ์ด ์ ๋ผ์...
ํ ๋ฒ์ 2๊ฐ ์์ฒญ์ด ๊ฐ๊ฑธ ๋ณด์loadMyInfo, loadPosts๊ฐ ๋ฐฑ์๋๋ก ์์ฒญ์ ๊ฐ๋ ๊ฑฐ ๊ฐ์๋ฐ,์ฌ๊ธฐ์์ ์ฟ ํค ์ ๋ฌ์ด ์ ๋๋์งconst cookie = context.req ? context.req.headers.cookie : ''; axios.defaults.headers.Cookie = ''; if (cookie) { axios.defaults.headers.Cookie = cookie; }(์ฌ์ง)my์ null์ ๋ฐํํ๋ ๊ฑฐ ๊ฐ๋ค์.. SSR์ด๋ผ์ ๊ทธ๋ฐ์ง๋ ๋ชจ๋ฅด๊ฒ ์ง๋ง ์๋ก๊ณ ์นจ ์ดํ Network ํญ์ ์๋ต ์จ๊ฒ ํ์ธ์ด ์ ๋๋ค์.. html css js ๋ฐ๊ธฐ ์ ์ data๋ฅผ ๋ถ๋ฌ์ค๋ ๊ฑฐ๋ผ์..?(์ฌ์ง)ํ๋ก ํธ์์pages/index ๋ ์ด๋ฐ ์์ผ๋ก ์ฝ๋๋ฅผ ์ง๋์๊ตฌ์.import wrapper from '../store'; import { useSelector, useDispatch } from 'react-redux'; import { loadMyInfo } from "../store/thunks/user"; import { loadPosts } from "../store/thunks/post"; import React, { useState, useEffect } from "react"; import type { NextPage } from 'next'; import RootState from "../store/state-types"; import axios from "axios"; import AppLayout from '../components/AppLayout'; import PostForm from '../components/PostForm'; import PostCard from '../components/PostCard'; import Link from "next/link"; const Home: NextPage = () => { const { my } = useSelector((state: RootState)=>state.user); const { mainPosts, loadPostsLoading, bringMorePosts } = useSelector((state: RootState)=>state.post); const dispatch = useDispatch(); const [prevLastId, setPrevLastId] = useState(-1); // useEffect(()=>{ // if(mainPosts.length { const handleScroll = () => { if(window.scrollY + document.documentElement.clientHeight > document.documentElement.scrollHeight - 300){ if(!loadPostsLoading && bringMorePosts){ if(prevLastId != mainPosts[mainPosts.length - 1]?.id){ dispatch(loadPosts({ lastId: mainPosts[mainPosts.length - 1]?.id })); } setPrevLastId(mainPosts[mainPosts.length - 1]?.id); } } } window.addEventListener("scroll", handleScroll); return () => { window.removeEventListener("scroll", handleScroll); } }, [loadPostsLoading, bringMorePosts]) return ( {my !== null && } {mainPosts.map((post)=>(post.Retweet ? : ))} ) } export const getServerSideProps = wrapper.getServerSideProps(async (context)=>{ const cookie = context.req ? context.req.headers.cookie : ''; axios.defaults.headers.Cookie = ''; if (cookie) { axios.defaults.headers.Cookie = cookie; } await context.store.dispatch(loadMyInfo()); await context.store.dispatch(loadPosts({})); // console.log(context.req); }); export default Home;๊ทธ๋ฆฌ๊ณ ํ๋ก ํธ์์ cookie๋ฅผ console.log์ ํ๊ณ ์ถ์๋ฐ npx pm2 kill์ ํ๊ณ ํฐ๋ฏธ๋ kill์ ํด๋ ์ ๋ธ๋ผ์ฐ์ ๊ฐ ์ด์์์ด์ npm start๋ฅผ ํ๋ฉด already in use ::80 ์๋ฌ๊ฐ ๋จ๋ค์..์๊ธด๊ฒ np2 pm2 reload all ์ ํ๊ณ list๋ณด๋๊น ์๋ฌด๊ฒ๋ ์๊ณ ์ ใ ใ ใ (์ฌ์ง)๊ทธ๋์.. ์ฟ ํค๊ฐ ์ ๋ฐ์์ง๋ ๊ฑด ์ด๋์์ ์์๋ ๋ฒ๊ทธ์ธ์ง ๊ฐ์ด ์ ์กํ๋๋ฐ ๋์์ฃผ์ค ์ ์์๊น์ ์์...
- 0
- 11
- 2.5K
Q&A
Application > Cookies ์ front์๋ง ์ ์ฅ์ด ์ ๋ผ์...
์ ๋ก์ด๋ ๋๋ถ์ ์ฟ ํค์ domain ๋ฃ๋ ๊ฑฐ๋ ์ฑ๊ณต ํ๋๋ฐ, domain ๋ฃ๋ ๊ฑฐ๋ ์๋ก๊ณ ์นจ ์ ๋ก๊ทธ์ธ ํ๋ฆฌ๋ ๊ฑด ๋ค๋ฅธ ๋ฌธ์ ์ธ๊ฐ์? ๊ฐ์ฌํฉ๋๋ค.
- 0
- 11
- 2.5K
Q&A
Application > Cookies ์ front์๋ง ์ ์ฅ์ด ์ ๋ผ์...
ํ๋ก ํธ& ๋ฐฑ์๋ ์ฟ ๊ธฐ ๋ค ์ง์ฐ๊ณ ๋ค์ ๋ก๊ทธ์ธ ์๋ํ์๋ํ๋ก ํธ Network ํญdomain=.shinyoungyou.com์ ์๋ค์(์ฌ์ง)
- 0
- 11
- 2.5K
Q&A
Application > Cookies ์ front์๋ง ์ ์ฅ์ด ์ ๋ผ์...
์๋ก๊ณ ์นจ ํ ๋ก๊ทธ์ธ ์๋ ํ์ ๋ํ๋ก ํธ (์ฌ์ง)(์ฌ์ง)๋ฐฑ์๋ (์ฌ์ง)
- 0
- 11
- 2.5K
Q&A
Application > Cookies ์ front์๋ง ์ ์ฅ์ด ์ ๋ผ์...
์์ NODE_ENV ์ปจ๋์ ์ ๋นผ๋ณด๊ณ ๋ค์ ๋ก๊ทธ์ธ ์๋ ํ๋๋ฐ๋ ๋๊ฐ์์์ฌ์ง ๋ถ์ฌ๋ ์๋ฏธ๋ ์๊ฒ ์ง๋ง..(์ฌ์ง)(์ฌ์ง)
- 0
- 11
- 2.5K
Q&A
Application > Cookies ์ front์๋ง ์ ์ฅ์ด ์ ๋ผ์...
ํน์ ๋ธ๋ผ์ฐ์ ์ ์บ์๊ฐ ์์ฌ์ ๋ณ๊ฒฝ๋ ์ฝ๋๊ฐ ๋ฐ์์ด ์๋๊ฑฐ๋ ๊ทธ๋ฌ๊ธฐ๋ ํ๋์..?
- 0
- 11
- 2.5K
Q&A
Application > Cookies ์ front์๋ง ์ ์ฅ์ด ์ ๋ผ์...
๋ค๋ค "start": "cross-env NODE_ENV=production pm2 start index.js",์ด๊ฑฐ๋ฅผ ํด์ฃผ๊ณ npx pm2 kill ํ๋ค๊ฐ npm start๋ฅผ ํ๊ณ , ํ ๋ฒ ๋ ํ์ธ์ ์ํด process.env.NODE_ENV๊น์ง ํ๋ฉด์ ์ฐ์ด๋ณด์์ต๋๋ค..
- 0
- 11
- 2.5K
Q&A
Application > Cookies ์ front์๋ง ์ ์ฅ์ด ์ ๋ผ์...
production ํ๊ฒฝ์ธ๊ฑด ๋ง๋ ๊ฑฐ ๊ฐ์์...
- 0
- 11
- 2.5K