묻고 답해요
169만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
미해결Node.js 교과서 - 기본부터 프로젝트 실습까지
GCP관련질문입니다.
제로초님이 하신대로 gcp 컴퓨트엔진으로 생성해서초기설정(apt-get update, npm 설치등등)하고 express-generator로 express 제일 기본앱을 만들었는데외부아이피로 3000포트 붙여서 접속해도 계속 로딩만 돌고 접속이 안되어서 질문드립니다. 혹시 방화벽 문제인가 싶어서 방화벽도 수신,송신을 3000을 다 열어놨는데도 안되고그래서 bin/www열어서 3000포트를 80번 포트로 바꿨더니`Port 80 requires elevated privileges`라는 에러가 뜨네요어떻게 해결하면 좋을지 조언을 구합니다.강의 감사히 보고있습니다~!!
-
미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
404에러가 뜨는데 원인을 계속 찾지 못하고 있습니다 ㅜㅜ
type(pin):"login_user" ▶ payload(pin) message(pin):"Request failed with status code 404" name(pin):"Error" stack(pin):"Error: Request failed with status code 404 at createError (http://localhost:3000/static/js/0.chunk.js:909:15) at settle (http://localhost:3000/static/js/0.chunk.js:1130:12) at XMLHttpRequest.handleLoad (http://localhost:3000/static/js/0.chunk.js:384:7)" ▶ config(pin):{ url: "/api/users…", method: "post", data: "{"email":"…", … } error(pin):true 강사님 깃헙 코드랑 비교하면서 계속 확인해도 문제가 계속 발생하는데 어디서 문제인 것인지 감이 오지 않습니다 ㅜㅜ 유튜브 댓글에 다른 분도 proxy 문제였는줄 알았다가 디렉토리 이름 문제였다고 하고ㅜㅜ localhost도 서버쪽은 5000으로 맞춰놨거든요.... 깃헙에 코드는 업로드 하였습니다. https://github.com/comejtome508/Practice_boilerplate
-
미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
heroku 관련 질문입니다
안녕하세요. 강의 너무나 잘 보고 있습니다. 이번 강의를 수강하는 도중에 갑자기 heroku가 갑자기 나오길래 이전 강의에서 놓친 부분이 있나 확인해보았는데 그 전에 언급하신 적은 없더라구요. 저는 아직 heroku를 사용해 본적이 없어서, heroku 홈페이지에서 계정을 만든 후, app을 만든다음, setting 부분의 Config vars에서 강의에서 하신 것 처럼 MONGO_URI를 추가하였습니다. npm run start는 정상적으로 작동을하는데, 혹시 제가 추가적으로 setting을 해야할 것들이 있을까요?
-
미해결따라하며 배우는 노드, 리액트 시리즈 - 챗봇 사이트 만들기
환경변수가 어디서 쓰이는지 잘 모르겠습니다 ㅠ
전체적인 구조는 잘 설명해 주셔서 이해했습니다! 클라이언트 - 노드 서버 - dialogflow API 이렇게 되는데, 이번 강의에서 노드 라우트에서 보면 제가 dialogflow에서 만든 계정 정보(프로젝트 아이디 등등)를 가지고서 세션을 형성해서 연결하는 것까지 이해했습니다! 그래서 그 특정 정보를 가지고 제 계정으로 만들었던 dialogflow API로 보내게 되는 거구요! 그런데, GOOGLE_APPLICATION_CREDENTIALS 환경변수를 만들긴 했는데 이것이 어디에 쓰이는지 모르겠습니다... ㅠ '프로젝트 이름-key.json' 라는 파일 안에는 제가 생성한 dialogflow 프로젝트 정보가 들어 있는데요, 이것이 있는 파일 경로를 이용해 일단 환경 변수를 셋팅했는데, 딱히 코드 상에서는 해당 환경 변수를 이용하는 곳이 없더라구요... ㅠ 그런데 서버를 돌리고 포스트맨으로 요청을 보내면 잘 응답이 오는 것을 확인할 수 있었습니다. 즉, 현재 노드 서버와 dialogflow API가 연결이 잘 됐다는 뜻인데요, 왜 이게 가능한지 모르겠습니다... const projectId = config.googleProjectID; const sessionId = config.dialogFlowSessionID; // 내 계정을 이용하여 dialogflow와의 세션 생성 const sessionClient = new dialogflow.SessionsClient(); const sessionPath = sessionClient.sessionPath(projectId, sessionId); 위에서 보시면 그저 프로젝트 이름하고, 임의로 정한 세션 아이디명을 넣어준 것 뿐인데, 어떻게 노드 서버가 제 dialogflow 프로젝트를 특정하여 잘 연결하는지 원리를 모르겠습니다...
-
미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
postman에서 POST 방식으로 데이터를 넣어봤는데, html 코드로 cannot POST만 확인됩니다.
현재 회원가입 기능까지 구현하고, postman에서 POST 방식으로 데이터를 넣어봤는데, html 코드로 cannot POST만 확인되어서 무엇이 문제인지 궁금합니다.
-
미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
dispatch(loggoutUser())
회원가입/로그인은 dispatch를 통해서 redux에 상태를 전달하는 것으로 봐서 로그아웃도 마찬가지라고 생각했는데요! 여기에서는 왜 dispatch대신 응답을 통해 넘어온 sucess메세지만으로 로그아웃을 마무리하는지 알 수 있을까요~?
-
해결됨Node.js에 TypeScript 적용하기(feat. NodeBird)
Error: Unknown authentication strategy "local"
완성된 백엔드랑 프론트 vue를 연결시키고 있습니다. db생성, 회원가입 까지는 정상적으로 작동합니다. 그런데 routes/user의 login의 passport.authenticate('local'~ 부분에서 Error: Unknown authentication strategy "local" 라는 에러가 발생합니다. passport/local 에 passport.use('local' ~)은 제대로 작성이 되어 있습니다!
-
해결됨따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
process.env.NODE_ENV
강의 너무나 잘보고 있습니다.궁금한 게 있는데 process.env는 제가 설정을 따로 안했는데도 쓸 수 있는걸 보니,노드를 설치하면 따라오는 process객체를 통해 접근하는 거로 이해가 가는데요.그렇다면 1.NODE_ENV도 노드설치시 process.env객체 안에 자동으로 있는 key이기에 사용가능한가요? 2. process.env.NODE_ENV === 'production'은 헤로쿠 통해 배포시에 사용하는 것은 알겠는데 npm start 실행시 production일지 / dev일지는 제가 따로 안 준것 같은데 별 말 없으면 노드는 자동으로 dev모드로 실행하는 건가요???
-
미해결Vue로 Nodebird SNS 만들기
trough, as
제로초님 강의 잘 보고 있습니다. 문서를 봐도 이해가 잘안되서 그러는데여.. sequlize associate부분에서 through,as가 무슨 역할인지 알려주실수 있을가요?? 강의 돌려봐도 좀 어렵네여 ㅠ
-
미해결Node.js 웹개발로 알아보는 백엔드 자바스크립트의 이해
1분20초 부분에서 submit을 눌러도 반응이 없는데 어떤문제일까요???
1분20초 부분에서 submit을 눌러도 반응이 없는데 어떤문제일까요???
-
미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
User.js 에서 this
userSchema.pre("save", function (next) { var user = this; if (user.isModified("password")) { bcrypt.genSalt(saltRounds, function (err, salt) { ... var user = this 를 하면 user 에는 뭐가 담기게 되는거죠?ㅠㅠ 또 여기서 var user = this 를 선언을 했는데 userSchema.methods.generateToken = function (callback) { var user = this; var token = jwt.sign(user._id.toHexString(), "secretToken"); ... 왜 여기서 또 선언을 하는 거에요? User.js 에서 user 이라는 변수가 뭔지 정확히 모르겠습니다ㅠㅠ
-
해결됨따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
안녕하세요.
추가적으로 궁금한점이 있어서 이렇게 남깁니다. 로그아웃 버튼을 클릭하면 mongoDB에 token이 "" 사라지게 구현해놓으셨는데, ie에서 application > cookies에서는 아직 token이 계속 있더라구요.. 상관이 없을까요?
-
해결됨따라하며 배우는 노드, 리액트 시리즈 - 유튜브 사이트 만들기
파일필터
파일필터 정상작동여부 판단을 위해서 mp4가 아닌 png를 올려보앗는데 업로드폴더에 들어갑니다 ㅠㅠ
-
미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
postman에서 계속 로딩 뜨시는 분들
저도 postman에서 계속 로딩만 뜨길래 오타났나 계속 찾다가, 강사님 답변 보고 해결해서 여기에 글 남겨요. /User.js 파일 에서 userSchema.methods.comparePassword 구문 안 bcrypt.compare 안에 있는 if문 수정하시면 잘 됩니다. if(err) return cb(err); // 맨 끝에 ,(콤마)아니고 ;(세미콜론)으로 해주셔야 합니다! cb(null,isMatch);
-
미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
TypeError: Cannot read property 'prototype' of undefined
https://github.com/ryun3433/inf-todo.git 깃헙주소입니다. 이런 에러가 계속 납니다 ㅠ.ㅠ 뭐가 문제인지 잘 모르겠습니다.. 도와주시면 정말 감사하겠습니다 TypeError: Cannot read property 'prototype' of undefined (anonymous function) C:/Users/patmo/Documents/myProject/inf-todo/client/node_modules/express/lib/response.js:42 39 | * @public var res = Object.create(http.ServerResponse.prototype)
-
미해결따라하며 배우는 노드, 리액트 시리즈 - 기본 강의
도와주세요...
계속 붙잡고 있어도 안되서 헬프를 칩니다.. 뭐가 문제인거죠..? auth.js 파일에서 findbytoken을 만드는데 계속 안되기만 합니다. TypeError: User.findByTokenis not a function at auth (C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\middleware\auth.js:8:10) at Layer.handle [as handle_request] (C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\express\lib\router\layer.js:95:5) at next (C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\express\lib\router\route.js:137:13) at Route.dispatch (C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\express\lib\router\route.js:112:3) at Layer.handle [as handle_request] (C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\express\lib\router\layer.js:95:5) at C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\express\lib\router\index.js:281:22 at Function.process_params (C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\express\lib\router\index.js:335:12) at next (C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\express\lib\router\index.js:275:10) at cookieParser (C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\cookie-parser\index.js:71:5) at Layer.handle [as handle_request] (C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\express\lib\router\layer.js:95:5) at trim_prefix (C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\express\lib\router\index.js:317:13) at C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\express\lib\router\index.js:284:7 at Function.process_params (C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\express\lib\router\index.js:335:12) at next (C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\express\lib\router\index.js:275:10) at C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\body-parser\lib\read.js:130:5 at invokeCallback (C:\Users\AndrewLee\Desktop\node_basic\boilerPlate\node_modules\raw-body\index.js:224:16)ㄱ계속 이 문구만 뜨고요 함수가 아니라는데 저는 함수를 user.js에 만들었고.. 아 이게 무슨 문제일까요.. auth.js const { User } = require('../models/user'); let auth = (req, res, next) => { // 이곳에서 인증처리를 하는 곳 // 클라이언트 쿠리에서 토큰을 가져온다 ==> 쿠키 파서를 이용한다. let token = req.cookies.x_auth; console.log('auth/token :' + token); // 토큰을 복호화한 후 유저를 찾는다. User.findByToken(token, (err, user) => { if (err) throw err; if (!user) { return res.json({ isAuth: false, error: true })// 유저가 없으니까 } else { // 유저가 있으면 req.token = token; // 이렇게 설정해주는 이유는 콜러에서 req.token , req.user와 같이 사용할 수 있게 하기 위해서이다. req.user = user; next(); } }); // 유저가 있으면 인증 오케이 // 유저가 없으면 인증 노노 } module.exports = {auth}; user.js const mongoose = require('../node_modules/mongoose'); const bcrypt = require('bcrypt'); const saltRounds = 10; const myPlaintextPassword = 's0/\/\P4$$w0rD'; const someOtherPlaintextPassword = 'not_bacon'; var jwt = require('jsonwebtoken'); const userSchema = mongoose.Schema({ name :{ type:String, maxlength:50 }, email:{ type:String, trim:true, //스페이스를 없앤다 unique : 1 // 유일한 특성 }, password :{ type:String, minlength:5 }, lastname:{ type:String, maxlength:50 }, role:{ // 롤을 주는 이유는 유저의 관리권한을 부여하기 위해서 type: Number, defalut: 0 }, image:String , token:{ // 토큰을 이용해서 유효성등을 나중에 관리함 type: String }, tokenExp :{ // 토큰의 유효기간 type:Number } }) userSchema.pre('save', function (next) { var user = this; console.log('1'); if (user.isModified('password')) { console.log('2'); bcrypt.genSalt(saltRounds, function (err, salt) { console.log('3'); if (err) return next(err); console.log('4'); bcrypt.hash(user.password, salt, function (err, hash) { console.log('5'); if (err) return next(err); console.log('6'); console.log(hash); user.password = hash; next(); }); }); }else{ next(); } }) userSchema.methods.comparePassword = function(planPassword,cb){ bcrypt.compare(planPassword,this.password,function(err,isMatch){ if(err) return cb(err); cb(null,isMatch); } ); } userSchema.methods.generateToken =function(cb){ var user = this; // json웹토큰을 이용해서 토큰을 생성하기 var token = jwt.sign(user._id.toHexString(), 'hihello'); // 이렇게 토큰을 만들면 ,, // user._id + hihello = token이 되고, 나중에는 token과 hihello로 user._id를 만들 수 있다. user.token = token ; user.save(function(err,user){ if(err) return cb(err); // 에러가 났으면 에러를 전달 cb(null,user); // 문제가 없으면 에러는 없고 유저를 전달 자 그럼 index.js로 넘어가서~ }); } userSchema.methods.B= function(token,cb){} userSchema.methods.findByToken= function(token,cb){ var user = this; // 토큰을 디코드 한다. user_id + '' = token console.log("1 : " + token ); jwt.verify(token, 'hihello',function(err,decoded){ // 유저 아이디를 이용해서 유저를 찾은 다음에 // 클라이언트에서 가져온 token과 db에 보관된 토큰이 일치하는지 확인 user.findOne({"_id":decoded,"token":token},function(err,user){ if(err){ return cb(err); }else{ cb(null, user); } }) }) } const User = mongoose.model('User',userSchema); console.log(User.comparePassword); module.exports = {User}; 좋은 강의 항상 감사드립니다.
-
해결됨따라하며 배우는 노드, 리액트 시리즈 - 유튜브 사이트 만들기
노드 리액트 기초 강의 #12 토큰 생성 with jsonwebtoken 강의 중 오류 ㅠㅠ
기초 강의 12번 부분에서 이러한 에러가 나는데 이유를 못찾겠습니다. ㅠㅠ 윗 부분은 제 소스코드입니다. 비밀번호를 틀리게 보내면 loginSuccess: false로 제대로 오는데 비밀번호를 올바르게하면 맨 윗 사진과같이 답변이 오네요 ㅠㅠ
-
미해결Node.js 웹개발로 알아보는 백엔드 자바스크립트의 이해
network status가 200이 아니라 304가 뜨는데 왜 그런걸까요?
network status가 200이 아니라 304가 뜨는데 왜 그런걸까요?
-
미해결테스트주도개발(TDD)로 만드는 NodeJS API 서버
Wrapping 의 뜻이 잘 이해가 안 갑니다.
app.get('/', function(req, res){ res.send('Hello World!'); }); 이 부분에서 http 의 req, res를 한번 wrapping 한 express의 객체라고 하셨는데 그 의미가 이해가지 않습니다 ㅜㅜ
-
미해결Node.js 교과서 - 기본부터 프로젝트 실습까지
10장 4절 오류 메시지
안녕하세요? API <-> Call 간에 다음과 같은 오류 메시지가 발생하네요... web(localhost:8003/test)오류 메시지 :: Error: secret option required for sessions at session (C:\Users\pleoc\OneDrive\Documents\Start_up\javawork\nodebird-call\node_modules\express-session\index.js:200:12) at Layer.handle [as handle_request] (C:\Users\pleoc\OneDrive\Documents\Start_up\javawork\nodebird-call\node_modules\express\lib\router\layer.js:95:5).................console terminal Message ::[nodemon] starting `node app.js` express-session deprecated req.secret; provide secret option app.js:18:9 8003 '번 포트에서 대기중' GET /test 500 621.475 ms - 1444 express-session option 문제인 것 같은데, 도움을 받을 수있을까요?감사합니다.