Skip to content
Snippets Groups Projects
Commit 1c345b79 authored by Hyun Woo Jeong's avatar Hyun Woo Jeong
Browse files

댓글 작성 전 준비

parent 21c5f223
No related branches found
No related tags found
No related merge requests found
......@@ -31,7 +31,7 @@ router.post('/login', async (req, res) => {
console.log('login done')
req.session.sessionid = req.body; //프론트에서 건네받은 JWT로 세션 생성
res.cookie('name', req.body.name, {expires}); //사용자 이름 쿠키
res.cookie('name', JSON.stringify({name:req.body.name, id:req.body.email}), {expires}); //사용자 이름 쿠키
res.send(req.body.name); // 이름 보내서 뭐하게?
......
......@@ -38,7 +38,7 @@ app.use(
); //cors 설정을 한다..
// app.use(express.static(path.join(process.cwd(), '../public')));
app.use(express.static('public'))
app.use(express.static('files'))
app.use(cookieParser());
app.use(express.json());
......
......@@ -15,7 +15,7 @@ export const router = express.Router();
const upload = multer({
storage: multer.diskStorage({ // 저장한공간 정보 : 하드디스크에 저장
destination(req, file, done) { // 저장 위치
done(null, 'public/uploads/'); // uploads라는 폴더 안에 저장
done(null, 'files'); // uploads라는 폴더 안에 저장
},
filename(req, file, done) { // 파일명을 어떤 이름으로 올릴지
const ext = path.extname(file.originalname); // 파일의 확장자
......
......@@ -20,8 +20,8 @@ function Article({ data }) {
// http://localhost:8080/uploads/21701487062905.png
return (
<img
src={`http://localhost:8080/${el.replaceAll("\\", "/").substring(7)}`}
alt={`http://localhost:8080/${el.replaceAll("\\", "/").substring(7)}`}
src={`http://localhost:8080/${el.replaceAll("\\", "/").substring(5)}`}
alt={`http://localhost:8080/${el.replaceAll("\\", "/").substring(5)}`}
style={{ width: "100px", height: "100px" }} />
)
});
......
......@@ -8,17 +8,6 @@ import { Link, useNavigate, Navigate } from "react-router-dom";
import cookie from 'react-cookies';
import {useCookies} from 'react-cookie'
function Welcome(props){
return (
<p>
{props.name?`${props.name}님, 환영합니다`:'로그인하세요.'}<br/>
</p>
)
}
function ButtonLink({link, status, children}){
const userContext = useContext(UserContext);
......@@ -45,14 +34,14 @@ function ButtonLink({link, status, children}){
}
function Header({islogged, username}){
const name = cookie.load('name')
const userinfo = cookie.load('name')
return(
<div className="header">
<ButtonLink link='/'>
<img className="logo_image" alt="logo" src={logo}/>
</ButtonLink>
<ul>
<p>{name?`${name}님, 환영합니다`:'로그인하세요.'}</p>
<p>{userinfo?`${userinfo.name}님, 환영합니다`:'로그인하세요.'}</p>
<ul className="menu_list">
<li><ButtonLink link='/'>Home</ButtonLink></li>
<li><ButtonLink link='/search'>검색</ButtonLink></li>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment