title: What should I do when the axios req.body undefined problem occurs?
body: <p>It was supposed to work, but suddenly from server, req.The body is marked as undefinde.</p>
  <p>Body-parser is already in use on the server. It works fine when you send a query to Postman.</p>
  <p>There is a problem at the stage of sending from the client to the server.</p>
  <pre class="lang-js prettyprint-override"><code>
  axios.post(
            `${process.env.REACT_APP_API_URI}/auth/signin`,
            {
              username: signinInfo.username,
              password: signinInfo.password,
            },
            { headers: { &quot;Content-Type&quot;:&quot;application/json&quot;  },      
          }
          )
          .then((res) =&gt; {
            console.log(signinInfo.username);
  
            localStorage.setItem(&quot;accessToken&quot;, res.data.accessToken);
  
            localStorage.setItem(
              &quot;subgatherUserInfo&quot;,
              JSON.stringify(res.data.data)
            );
  
            persistLogin(true);
  
            //  console.log(mypageOn(disabled) )
  
            navigate(&quot;/&quot;);
          })
          .catch((err) =&gt; {
            console.log(signinInfo.password, signinInfo.username);
  
            // mypageOff()
  
            mypageOn(false);
            setSigninInfo({ ...signinInfo, password: &quot;&quot; });
  
            setSigninErrMessage(&quot;아이디와 비밀번호를 정확히 입력해주세요&quot;);
            //로그인 정보가 맞지 않는경우. errmessage
            throw err;
          });
      }
  </code></pre>
  <p>node.js server</p>
  <pre class="lang-js prettyprint-override"><code>
  const express = require(&quot;express&quot;);
  const cors = require(&quot;cors&quot;);
  const cookieParser = require(&quot;cookie-parser&quot;);
  const app = express();
  const Port =process.env.PORT|| 5001;
  const {authchecker} = require('./middleware/authChecker');
  const authRouter = require('./routes/auth')
  
  const userRouter = require('./routes/user');
  const walletRouter = require('./routes/wallet')
  app.use(express.json()); //미들웨어
  
  app.use(express.urlencoded({ extended: true })); //미들웨어
  app.use(cookieParser()); // 미들웨어
  
  app.use(
    cors({
      origin: [process.env.CLIENT_URL,&quot;http://localhost:3000&quot;],
      methods: [&quot;GET&quot;, &quot;POST&quot;, &quot;PATCH&quot;, &quot;DELETE&quot;],
      credentials: true,
    })
  );
      
      
     
  //routes
  
  
  app.use(authchecker)
  
  app.use('/auth',authRouter)
  app.use('/user',userRouter)
  app.use('/wallet',walletRouter)
  
  
  
  // app.get(&quot;/&quot;, (req, res) =&gt; {
  //   res.send(&quot;Hello Nodes.js&quot;);
  // });
  
  app.listen(Port, () =&gt; {
    console.log(`Server is Startin on ${Port}`);
  });
  
  </code></pre>
  <p>login router</p>
  <pre class="lang-js prettyprint-override"><code>signinControl: async (req, res) =&gt; {
  
      const { username, password } = req.body;
  
    
      try {
        console.log(req.body,'login')
        
  
        // console.log(username,password)
  
        const salt = await user.findOne({
          attributes: [&quot;salt&quot;],
          where: { username:username },
        });
  
        //2. 유저 db에서 이메일 확인하기
  
        crypto.pbkdf2(
          password,
          salt.dataValues.salt,
          11011,
          64,
          &quot;sha512&quot;,
          async (err, key) =&gt; {
            if (err) {
              throw err;
            }
            const hardPassword = key.toString(&quot;base64&quot;);
  
            // console.log(hardPassword)
            const getUserInfo = await user.findOne({
              where: { username: username, password: hardPassword },
            });
            console.log(getUserInfo);
  
            if (!getUserInfo) {
              return res.status(401).send(&quot;이메일 및 비밀번호 확인&quot;);
            }
            const userUsername = getUserInfo.dataValues.username;
            const userNick = getUserInfo.dataValues.nickname;
            const userId = getUserInfo.dataValues.id;
            const isSocial = getUserInfo.dataValues.social_user;
            const isAdmin = getUserInfo.dataValues.isAdmin
            // const { email, nickname, id } = getUserInfo.dataValues;
            const accessToken = generateAccessToken({
              userUsername,
              userNick,
              userId,
              isAdmin,
              isSocial
            });
            const refreshToken = generateRefreshToken({
              userUsername,
              userNick,
              userId,
              isAdmin,
              isSocial
            });
            const accessExp = tokenExp(accessToken);
            const refreshExp = tokenExp(refreshToken);
  
            // console.log(accessToken)
  
            //referesh는 쿠키로, access는 활용할수 있도록 client로 보낸다.
            sendCookie(res, refreshToken);
  
            // console.log(req.exp, req.user, &quot;req.exp&quot;);
  
            return res.status(200).send({
              data: {
                id: userId,
                nickname: userNick,
                username: userUsername,
                social_user:false,
                isAdmin:false,
                accessExp: accessExp,
                refreshExp: refreshExp,
              },
              accessToken: accessToken,
            });
  
            // 토큰 생성 한다. 구글, 카카오 인경우도 있으므로 id이용
          }
        );
      } catch (err) {
        return res.status(500).send(err);
      }
  
  </code></pre>
  <p>postman setting &amp; result</p>
  <p>raw JSON
  {
  &quot;username&quot;: &quot;123456&quot;,
  &quot;password&quot;: &quot;123456456&quot;
  }</p>
  <p>content-type: application/json</p>
  <pre><code>&quot;data&quot;: {
      &quot;id&quot;: 1,
      &quot;nickname&quot;: &quot;123456&quot;,
      &quot;username&quot;: &quot;123456456&quot;,
      &quot;social_user&quot;: false,
      &quot;isAdmin&quot;: false,
      &quot;accessExp&quot;: 1658500545,
      &quot;refreshExp&quot;: 1658748945
  },
  &quot;accessToken&quot;: &quot; &quot;
  </code></pre>
  <p>}</p>