我使用Ruby on Rails構建了一些登錄令牌認證Apis,它在本地運行良好,我有一個內置到本地和heroku數據庫的用戶,如果我這樣做:API調用在本地工作,但不能在Heroku上工作
curl -v -H "Content-Type:application/json" -X POST -d '{"session":{"password":"12345678","email":"[email protected]"}}' http://api.zapserver.dev/sessions/
我可以從服務器獲得正確的JSON響應。
但是,當我做的Heroku同一呼叫,這將是這樣的:
curl -k -v -H "Content-Type:application/json" -X POST -d '{"session":{"password":"12345678","email":"[email protected]"}}' https://api.appname.herokuapp.com/sessions/
我得到了一個404 Not Found錯誤。
我已經完成了rails db:migrate
,我仍然有同樣的錯誤。
任何想法?
編輯
我從Heroku的日誌幾乎一無所有,我用了一個heroku logs --tail
命令和什麼都沒有發生。
下面是我從捲曲得到的錯誤消息:
* Trying 50.19.245.201...
* TCP_NODELAY set
* Connected to api.zapserver.heroku.com (50.19.245.201) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: *.herokuapp.com
* Server certificate: DigiCert SHA2 High Assurance Server CA
* Server certificate: DigiCert High Assurance EV Root CA
> POST /sessions/ HTTP/1.1
> Host: api.zapserver.heroku.com
> User-Agent: curl/7.51.0
> Accept: */*
> Content-Type:application/json
> Content-Length: 67
>
* upload completely sent off: 67 out of 67 bytes
< HTTP/1.1 404 Not Found
< Connection: keep-alive
< Server: Cowboy
< Date: Sun, 12 Feb 2017 14:30:09 GMT
< Content-Length: 494
< Content-Type: text/html; charset=utf-8
< Cache-Control: no-cache, no-store
<
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<title>No such app</title>
<style media="screen">
html,body,iframe {
margin: 0;
padding: 0;
}
html,body {
height: 100%;
overflow: hidden;
}
iframe {
width: 100%;
height: 100%;
border: 0;
}
</style>
</head>
<body>
<iframe src="//www.herokucdn.com/error-pages/no-such-app.html"></iframe>
</body>
* Curl_http_done: called premature == 0
* Connection #0 to host api.zapserver.heroku.com left intact
你的用戶是否存在於heroku上? –
'rake db:migrate',不是rails。錯字? –
rails db:migrate for rails for rails 5 –