• 카테고리

    질문 & 답변
  • 세부 분야

    풀스택

  • 해결 여부

    미해결

VideoDetailPage로 넘어갈 때 404 error

21.02.22 23:48 작성 조회수 166

0

랜딩페이지 로드할 때 DB에서 비디오 정보 가져올 때는 오류 없어 잘 돼는데

이상하게 디테일페이지에서 불러올때는 노드쪽(?) path 가  undefined 가 뜨네요ㅜㅜ 

오른쪽에 6032...저게 비디오 아이디랑 똑같은데 왜 저렇게 뜨는지 못찾겠어서요..!

페이지 로딩은 됩니다.. 영상 썸네일? 은 뜨는듯한데 재생은 또 안되구요..ㅜㅜ

그리고 어쩔때는 videoDetail이 이예 넘어오질 않습니다.

node 쪽 콘솔로 정보가 잘 왔는지 찍어보면 req.body 에 variable 이 없어요ㅜㅜ 깃헙 주소 남깁니다!

영상은 .mov 인데 이거는 비디오 업로드 시에 .mp4 와 || .mov 둘다 가능하게 작성하긴 했습니당

https://github.com/silverwest8/YoutubeCLONE

답변주시면 정말 감사하겠습니다!😀

답변 1

답변을 작성해보세요.

0

은서님 안녕하세요 답변이 너무 늦었네요 ㅠㅠ.... 혹시 이부분 해결하셨나요? 

최은서님의 프로필

최은서

질문자

2021.02.27

아닙니다!! 감사합니당 ㅎㅎ

아뇨ㅜㅜ 아무리 검색하고 삽질해도 req가 안넘어오는건 body-parser 때문이라는데

노드쪽 index.js 에 .json() 과 urlencoded()가 다 잘 되어있는데 왜 안되는지 모르겠네요...

아예 안되는것도 아니고 랜딩페이지 비디오 로딩은 잘 되다가 디테일페이지에서만 안되는 이유를 못찾고 있습니다!

너무 오래걸려서 일단 구독 부분으로 넘어가서 계속 하고 있는데 구독부분 구현에서도 req.body 가 그냥 [Object object]로만 떠서 어떻게해야할지 모르겠습니다.!

깃헙주소는 https://github.com/silverwest8/YoutubeCLONE 이고, 

한번 봐주실 수 있으면 감사하겠습니다!

 아래는 index.js파일입니다

const express = require("express");const app = express();const path = require("path");const cors = require('cors')const bodyParser = require("body-parser");const cookieParser = require("cookie-parser");const config = require("./config/key");// const mongoose = require("mongoose");// mongoose// .connect(config.mongoURI, { useNewUrlParser: true })// .then(() => console.log("DB connected"))// .catch(err => console.error(err));const mongoose = require("mongoose");const connect = mongoose.connect(config.mongoURI, { useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true, useFindAndModify: false }) .then(() => console.log('MongoDB Connected...')) .catch(err => console.log(err));app.use(cors())//to get json data// support parsing of application/json type post dataapp.use(bodyParser.json());//to not get any deprecation warning or error//support parsing of application/x-www-form-urlencoded post dataapp.use(bodyParser.urlencoded({ extended: true }));app.use(cookieParser());app.use('/api/users', require('./routes/users'));//videouploadpage 에서 여기로 왔다가 route로 감app.use('/api/video', require('./routes/video'));app.use('/api/subscribe', require('./routes/subscribe'));//use this to show the image you have in node js server to client (react js)//https://stackoverflow.com/questions/48914987/send-image-path-from-node-js-express-server-to-react-clientapp.use('/uploads', express.static('uploads'));// Serve static assets if in productionif (process.env.NODE_ENV === "production") { // Set static folder // All the javascript and css files will be read and served from this folder app.use(express.static("client/build")); // index.html for all page routes html or routing and naviagtion app.get("*", (req, res) => { res.sendFile(path.resolve(__dirname, "../client", "build", "index.html")); });}// const port = process.env.PORT || 4000;// const port = 4000 || process.env.PORT;const port = 4000;app.listen(port, () => { console.log(`Server Listening on ${port}`)});