7 글 보임 - 1 에서 7 까지 (총 7 중에서)
-
글쓴이글
-
2022년 8월 7일 11:07 #41132
이무헌참가자App.js <button type='submit' onClick={()=>{axios.get('https://eccwithnodejs.df.r.appspot.com:443/user').then((res)=>{console.log(res.data)}).catch(error => { console.log(error.response) });}} >버튼</button> server.js
app.get('https://eccwithnodejs.df.r.appspot.com:443/user',function(req,res){ var tempUser={"name":"asd", "birth":970204, "email":"으헤헤헤이거슨이메일", "uid":"유니크다음은 전설" }
res.send(tempUser); console.log(tempUser); }) 구글링을 해본 결과 https 프로토콜을 사용하기 위해선 ssl이 필요하고 openssl을 통해 다음과 같이 서버를 열었습니다.
var server=http.createServer(app).listen(8080,function(){ console.log('또 성공했구나..이녀석'); })
https.createServer(options,app).listen(443,function(){ console.log('또 또 성공했구나..이녀석'); }) 그럼에도 다음과 같은 오류가 뜨네요 ㅠ {data: '<!DOCTYPE html>\n<html lang="en">\n<head>\n<meta char…ody>\n
Cannot GET /user
\n</body>\n</html>\n', status: 404, statusText: '', headers: {…}, config: {…}, …}
문제가 뭔지 알 수 있을까요? ㅠㅠㅠ
2022년 8월 8일 13:27 #41287
이무헌참가자https로 통신하면 여전히404로 받질 못했습니다. ㅠㅠ 포트 8080 으로 http로 통신하니까 xhr.js:210 GET https://eccwithnodejs.df.r.appspot.com:8080/user net::ERR_CONNECTION_TIMED_OUT 이렇게 오류가 뜨네요.. 서버쪽으로 요청은 간 것 같은데 AppEngine쪽에 문제가 있는 걸까요? 아래는 선생님의 말씀에 따라 바꾼 코드입니다! App.js <button type='submit' onClick={()=>{axios.get('http://eccwithnodejs.df.r.appspot.com:8080/user').then((res)=>{console.log(res.data)}).catch(error => { console.log(error.response); });}} >버튼</button>
server.js
app.get('/user',function(req,res){ var tempUser={"name":"asd", "birth":970204, "email":"으헤헤헤이거슨이메일", "uid":"유니크다음은 전설" }
res.send(tempUser); console.log(tempUser); })
2022년 8월 8일 16:04 #41355
codingapple키 마스터https 라이브러리 설치하고 셋팅하는 코드가 잘못된게 아닐까요 근데 app engine에 올리면 appspot.com어쩌구 기본 도메인은 인증서 설치같은거 자동으로 되어있어서 그냥 https로 요청잘될 수도 있습니다 리액트에서 get요청시 뒤에 :8080은 없앱시다
-
글쓴이글
7 글 보임 - 1 에서 7 까지 (총 7 중에서)
- 답변은 로그인 후 가능합니다.