사용자가 전화 번호를 입력하고 enter를 클릭하여 twilio에서 구입 한 번호의 전화를 수신 할 수있게 해주는 웹 앱을 만들었습니다. 내 로컬 호스트 db에서 전화 번호를 가져 와서 수행합니다. 이제 heroku 서버에 웹 응용 프로그램이 있습니다. 하지만 내가 전화를 클릭하면 이러한 오류가 발생합니다.heroku 사이트에서 가져 오기
"리소스를로드하지 못함 : 지정된 호스트 이름을 가진 서버를 찾을 수 없습니다."
"처리되지 않은 약속 거부 : 형식 오류 : 입력 오류"내가 로컬 호스트에서 그것을 가져 오는 때
그것은 잘 작동했지만 지금은 문제가 있어요. 아무도 왜 이것이 일어나고 있는지 말해 줄 수 있습니까? 는"http://https://******.herokuapp.com"
이 (2 회 유의
http
) 유효한 서버가 아닌, 당신
JS이 오타없는 가정
const express = require("express");
const app = express();
const port = 3000;
app.get("/", function(req, resp){
resp.sendFile(__dirname+"/input.html");
});
app.get("/:data", function(req, resp){
var accountSid = 'accountsid'
var authToken = 'tokensid'
var client = require('twilio')(accountSid, authToken);
client.calls.create({
url: 'https://demo.twilio.com/docs/voice.xml',
to: req.params.data,
from: '3738373839',
});
html 파일
<input type="text" placeholder="Enter your number" id="inputNum" />
<button id="submitNum">Enter</button>
<script>
submitNum.addEventListener("click", function(){
var inputNum = document.getElementById("inputNum");
var submitNum = document.getElementById("submitNum");
var phoneNumber = inputNum.value;
fetch("https://******.herokuapp.com"
+ phoneNumber).then((resp)=>{
console.log(resp);
});
});
</script>
코드를 보지 않고 말하기는 어렵지만 (전체 서버 주소를 게시하지는 마십시오.) heroku의 앱은 로컬 데이터베이스에 액세스 할 수 없으므로 로컬로 가지고있는 호스트 버전 (mongo/postgres/etc)을 사용해야합니다. – xavdid
가져올 로컬이 아닌 데이터베이스를 설정 했습니까? 앱이 비 로컬 호스트에서 호스팅되는 경우 로컬 서비스와 통신 할 수 없습니다. –
위의 코드를 – RAY