9 ๊ธ ๋ณด์ - 1 ์์ 9 ๊น์ง (์ด 9 ์ค์์)
-
๊ธ์ด์ด๊ธ
-
2023๋ 5์ 9์ผ 14:16 #81955

์ ์ค์์ฐธ๊ฐ์
์ด๋ฐ ํ๋ฉด์ธ๋ฐ์ ์ ์คํจํ๋์ง ์ ๋ชจ๋ฅด๊ฒ ์ต๋๋ค.
vercel์๋ ๋ฐฐํฌ๋ฅผ ํด๋ดค๋๋ฐ
Comment.js ๋ชจ๋์ ์ฐพ์ ์ ์๋ค๊ณ ํ๋ค์ ํน์ ์ ๊ฐ ๋ญ ์๋ชปํ๊ฑธ๊น์?
/app/detail/[id]/page.js// dynamic route // (props)=>{}; ํ๊ณ , // console.log(props); ํด์ฃผ๋ฉด ์ ์ ๊ฐ ๋ค์ด๋๋ฏน๋ผ์ฐํฐ ์๋ฆฌ์์ ๋ ฅํ ๊ฐ์ด ์ฝ์์๋ธ // ๋ค์ด๋๋ฏน๋ผ์ฐํฐ๋?${id}๋ฅผ๋ปํจ ์ ์ฒด์์=> localhost:3000:/detail/${id} import { connectDB } from '@/util/database'; import { ObjectId } from 'mongodb'; import Link from 'next/link'; import Comment from './Comment'; import PostLike from '../../../component/PostLike'; import { getServerSession } from 'next-auth'; import { authOptions } from '@/pages/api/auth/[...nextauth]'; import { notFound } from 'next/navigation';const Detail = async (props) => { const session = await getServerSession(authOptions);let client = await connectDB; const db = client.db('forum');let result = await db .collection('post') .findOne({ _id: new ObjectId(props.params.id) });let postLike = await db .collection('postLike') .find({ postId: new ObjectId(props.params.id) }) .toArray();if (result === null) { return notFound(); }return ( <div className='container'> <h4 className='title mt-2 mb-3 '>์์ธํ์ด์ง</h4>
{result && ( <div className='list'> <div className='list-item'> {session && ( <div className='emoticon-box'> <Link href={`/edit/${result._id}`}>โ๏ธ</Link>โ </div> )}<h4> <span>{result.title}</span> </h4><span className='post-like-count'> ๏ฝฅ {postLike.length}</span> <p>{result.contents}</p><PostLike postId={props.params.id} session={session} /><Comment postId={result._id.toString()} /> </div> </div> )} </div> ); };export default Detail;
Comment.js์ ๋๋ค
'use client';
import { useEffect, useState } from 'react';const Comment = ({ postId }) => { const [comment, setComment] = useState(''); const [commentList, setCommentList] = useState([]); const [isComment, setIsComment] = useState(false); const [loading, setLoading] = useState(false);const onChangeCommentInput = (e) => { setComment(e.target.value); };const onSubmit = () => { fetch('/api/comment/new', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ comment, postId, }), }).then((data) => { if (data.status === 200) { setIsComment((prev) => !prev); setComment(''); } }); };useEffect(() => { setLoading(true); fetch(`/api/comment/list?id=${postId}`) .then((response) => response.json()) .then((data) => { setLoading(false); setCommentList(data); }); }, [isComment]);return ( <div className='comment-wrap'> <div style={{ marginBottom: '.5rem' }}>๋๊ธ ๋ชฉ๋ก</div>{loading ? ( <div className='loading'>Loading...</div> ) : ( <> {commentList && commentList.map((data) => ( <div key={data._id} className='comment-list'> <p className='comment-item'> {data.content} by- <span className='comment-name'>{data.authorName}</span> </p> </div> ))} </> )}<div className='comment-input-wrap'> <input type='text' value={comment} onChange={(e) => onChangeCommentInput(e)} className='comment-input' /> <button onClick={onSubmit} style={{ width: '25%' }}> ๋๊ธ์์ฑ </button> </div> </div> ); };export default Comment;
2023๋ 5์ 9์ผ 17:21 #82015
codingappleํค ๋ง์คํฐIAM ๊ฒ์ - ์ญํ ๋ค์ด๊ฐ์ https://stackoverflow.com/a/72682542 ์ด๋ฐ๊ฑฐ ํด๋ด ์๋ค Comment.js ํ์ผ ๊ฒฝ๋ก๊ฐ ์๋ชป๋๊ฒ ์๋๊น์
2023๋ 5์ 9์ผ 23:25 #82166
์ ์ค์์ฐธ๊ฐ์
์ ์๋ ์ฌ๊ธฐ์ ์ฝ๋์
๋ก๋ ์ ๊ฑฐ ์ ํํด์ ์ ํ๋ก์ ํธ ์์ถํ๊ฑฐ ์ฌ๋ฆฌ๋ฉด๋๋๊ฑฐ๋ง์๊น์?2023๋ 5์ 9์ผ 23:35 #82168
์ ์ค์์ฐธ๊ฐ์
๊ฐ์ ๊ธ๊ณผ๋ ์ข ๋ค๋ฅด๋๋ผ๊ตฌ์ ์ด๋ฐ์์ผ๋กํ๋๋ฐ ์ค์ ๋ง๊ฒํ๊ฑธ๊น์..
aws๋ ์๊ธํญํ๋ง์๊น๋ด ๋ญ๊ฐ ์กฐ์ฌ์ค๋ฝ๋ค์
์ด๋ฒ์ ๋ค๋ฅธ ์ค๋ฅ๋ฅผ ๋ง์ฃผ์ณค์ต๋๋ค. ์ ๊ฐ ์๋ชป๋ง์ง๊ฒ ๋ถ๋ช
ํ๊ธดํ๋ฐ ์ด๋ ต๋ค์..2023๋ 5์ 10์ผ 09:46 #82258
codingappleํค ๋ง์คํฐpackage.jsonํ์ผ ๋นผ๊ณ ์ฌ๋ ธ๋ค๋๊ฑฐ๊ฐ์ต๋๋ค ๋ก๊ทธ๋ฉ๋ด์์ ์๋ฌ๋ฉ์ธ์ง ์ถ๋ ฅํด๋ณผ ์ ์์ต๋๋ค
2023๋ 5์ 10์ผ 20:13 #82504
์ ์ค์์ฐธ๊ฐ์์ค ์ค ์ ๊ฐ ์์ถ์ ์๋ชปํ์๋๋ด์. ์์ถ ํ๊ณ ํ๋๊น ์ด๋ฒ์ ์๋ฌ๋ฉ์์ง๊ฐ ๋ฐ๋์๊ณ ์ฌ์ดํธ ๋ค์ด๊ฐ๋ณด๋ฉด 502 Bad Gateway ๋ผ๋ ๋ฌธ๊ตฌ๊ฐ ๋์ค๋ค์
์ด ์๋ฌ๋ฌธ๊ตฌ๋ ์ ๊ฐ I am ์ญํ ์ค์ ์ ์๋ชปํด์ค๊ฑด๊ฐ์?2023๋ 5์ 11์ผ 09:41 #82656
codingappleํค ๋ง์คํฐ๊ทธ๋ด์๋ ์์ต๋๋ค ์ด๋ป๊ฒ ์ค์ ํ์ต๋๊น
2023๋ 5์ 11์ผ 15:59 #82706
์ ์ค์์ฐธ๊ฐ์I AM ์ฌ์ฉ์ ์ญํ ์ AWSServiceRoleForElasticBeanstalk ์ค์ ์ด ๋์ด์๋๊ฒ ๊ธฐ๋ณธ์ ์ผ๋ก์์ด์ ๊ทธ๊ฑธ ์ฌ์ฉํ์ต๋๋ค. ์ฌ์ง์ฒ๋ผ์. ์ฌ์ง์ ์ฑ๋ง๋ค๊ณ , ํ๊ฒฝ๊ตฌ์ฑํ๋ ๋จ๊ณ์ค ์๋น์ค ์ก์ธ์ค ๊ตฌ์ฑ ๋จ๊ณ์ ๋๋ค. ์ ํ๋ธ๋ ๋ค์ ธ๋ณด๊ณ ํ๋๋ฐ ์ ํ๋ธ์ ๊ฐ์ฌ๋ ํ๋ฉด๊ตฌ์ฑ์ด ์ ํ๋ฉด๊ตฌ์ฑ๊ณผ ๋ฌ๋ผ์ ํค๋งค๊ณ ์๋ค์..
๊ทผ๋ฐ EC2 ์ธ์คํด์ค ํ๋กํ์ผ์ด ๋น์ด์์ด์ ๋๋ฌ๋ณด๋ฉด ๋ญ ์๋ฌด๊ฒ๋ ์์ต๋๋ค.
ํน์ ์ฌ๊ธฐ๋ฅผ ์ค์ ํด์ค์ผํ๋์?
์ถ๊ฐ๋ก ์ I am ์ฌ์ฉ์ ์ญํ ์ ์ด๋ฐ์์ผ๋ก ํด์ค์์ต๋๋ค.
๋ง๊ฒ ํ๊ฑธ๊น์?
++++ ์ถ๊ฐ
The instance profile aws-elasticbeanstalk-ec2-role associated with the environment does not exist.
๋ผ๋ ์ค๋ฅ๊ฐ ๊ณ์๋จ๋๋ฐ.. ์ ์ญํ ์ ์๋ ์ฌ์ง๊ณผ ๊ฐ์ต๋๋ค.
์ฌ๊ธฐ์ aws-elasticbeanstalk-ec2-role๋ผ๋ ์ด๋ฆ์ด ์์ด์ ๊ทธ๋ฐ๊ฑธ๊น์?
jung ์ญํ ๊ถํ์ ๋ค์๊ณผ๊ฐ์ด ์์ ํด์คฌ์ต๋๋ค.
2023๋ 5์ 11์ผ 23:50 #82779
codingappleํค ๋ง์คํฐhttps://codingapple.com/forums/topic/aws-%eb%b0%b0%ed%8f%ac-%eb%ac%b8%ec%a0%9c/ ์ฌ๊ธฐ์ฒ๋ผ ์ญํ 2๊ฐ๋ ๊ถํ ๋๊ฐ์ด ์ค์ ํด๋ด ์๋ค
-
๊ธ์ด์ด๊ธ
9 ๊ธ ๋ณด์ - 1 ์์ 9 ๊น์ง (์ด 9 ์ค์์)
- ๋ต๋ณ์ ๋ก๊ทธ์ธ ํ ๊ฐ๋ฅํฉ๋๋ค.
