• 로그인
  • 장바구니에 상품이 없습니다.

home2 게시판 Node.js, Express 게시판 구글클라우드

구글클라우드

6 글 보임 - 1 에서 6 까지 (총 6 중에서)
  • 글쓴이
  • #36294

    김대호
    참가자

    서버.js 

     db = client.db('notwait');
        app.listen('8080', function () {
          console.log('listening on 8080');
        });
        app.get('/Customer/:id', function (요청, 응답) {
          응답.sendFile(path.join(__dirname, '/notwait/dist/index.html'));
        });
        app.get('/Owner', function (요청, 응답) {
          응답.sendFile(path.join(__dirname, '/notwait/dist/index.html'));
        });
        app.post('/Login', function (요청, 응답) {
          db.collection('code')
            .find({ _id: 요청.body.code })
            .toArray()
            .then(data => {
              if (data.length === 0) {
                응답.send('Wrong information');
              } else if (data[0].onoff == 1) {
                var b = [];
                db.collection('menu')
                  .find({ _id: 요청.body.code })
                  .toArray()
                  .then(a => {
                    b.push(a[0]);
                  });
                db.collection('table')
                  .find({ _id: 요청.body.code })
                  .toArray()
                  .then(a => {
                    setTimeout(() => {
                      b.push(a[0]);
                      응답.send(b);
                    }, 500);
                  });
              } else {
                응답.send('Period is over');
              }
            });
        });

     

    store.js

    owner_login(context, payload) {
          axios
            .post(
              '/Login',
              { code: payload },
              {
                onDownloadProgress: ProgressEvent => {
                  let percentage =
                    (ProgressEvent.loaded * 100) / ProgressEvent.total;
                  let percentcompleted = Math.round(percentage);
                  context.commit('owner_login_percentage', percentcompleted);
                },
              }
            )
            .then(response => {
              if (response.data.length < 2) {
                context.commit('owner_event_modalOnOff', 'Please reconnect');
              } else if (response.data == 'Wrong information') {
                context.commit('owner_event_modalOnOff', 'Wrong information');
              } else if (response.data == 'Period is over') {
                context.commit('owner_event_modalOnOff', 'Period is over');
              } else {
                context.commit('login', response);
              }
            });

     

    로컬호스트로는 잘 작동되던게

    구글클라우드로 배포해서 접속하니 모든 post.get요청이 작동안하네요,...

    ERR_QUIC_PROTOCOL_ERROR 200

    502 오류도 뜨는데 어떻게 하나요?

    ajax path부분을 할당받은주소/Owner 이런식으로 해야하나요?

    #36304

    codingapple
    키 마스터

    다른 브라우저나 폰으로 접속해도 그렇습니까

    #36321

    김대호
    참가자

    #36322

    김대호
    참가자

    다시보니 get ,post요청 잘되는것같습니다

    근데 

    sse가 제대로 작동안하고(502 error),

     onDownloadProgress: ProgressEvent => {
                  let percentage =
                    (ProgressEvent.loaded * 100) / ProgressEvent.total;
                  let percentcompleted = Math.round(percentage);

    get요청한걸 progressbar로 만들어서 사용중인데 이부분도 안되네요

    app.get('/Owner/Sync', function (요청, res) {
          res.writeHead(200, {
            'Content-Type': 'text/event-stream',
            'Cache-Control': 'no-cache',
            Connection: 'keep-alive',
          });
          var 문서2;
          const talk = db.collection('table').watch();
          talk.on('change', result => {
            문서2 = result.updateDescription.updatedFields;
            var n = Object.keys(문서2).toString();
            let num = Number(n.substr(6, 1));
            res.write('event: test\n');
            res.write('data: {\n');
            res.write(`data: "data":  ${JSON.stringify(문서2)},\n`);
            res.write(`data: "index": ${num}\n`);
            res.write('data: }\n\n');
          });
        });

    #36350

    codingapple
    키 마스터

    구글클라우드 콘솔 로그탐색기 들어가서 서버로그에 나오는 에러메세지들도 확인해봅시다 

    #36383

    김대호
    참가자

    흐음 해결이 어려워서 aws도 간편하길래 적용해보니 잘되네용 답변 감사합니당

6 글 보임 - 1 에서 6 까지 (총 6 중에서)
  • 답변은 로그인 후 가능합니다.

About

현재 월 700명 신규수강중입니다.

  (09:00~20:00) 빠른 상담은 카톡 플러스친구 코딩애플 (링크)
  admin@codingapple.com
  이용약관
ⓒ Codingapple, 강의 예제, 영상 복제 금지
top

© Codingapple, All rights reserved. 슈퍼로켓 에듀케이션 / 서울특별시 강동구 고덕로 19길 30 / 사업자등록번호 : 212-26-14752 온라인 교육학원업 / 통신판매업신고번호 : 제 2017-서울강동-0002 호 / 개인정보관리자 : 박종흠