heroku 给了我不允许的方法
Posted
技术标签:
【中文标题】heroku 给了我不允许的方法【英文标题】:heroku is giving me Method not allowed [closed] 【发布时间】:2018-01-15 15:35:42 【问题描述】:好的,所以我已经解决了这个问题几个小时了,不知道如何解决这个问题,因为我只是一个新手。我正在学习 Colt Steele 的名为 WEBDEVBOOTCAMP 的 UDEMY 课程。在部署部分,每次我使用 Heroku 进行部署时,都会出现“不允许的方法”。我一直从头开始遵循柯尔特的方式,这就是为什么我想知道为什么会这样。
请帮忙。
顺便说一句,这些是我收到的 heroku 日志:
2017-08-07T21:45:10.990742+00:00 heroku[web.1]: Starting process with command `npm start`
2017-08-07T21:45:14.881336+00:00 app[web.1]:
2017-08-07T21:45:14.881350+00:00 app[web.1]: > v1@1.0.0 start /app
2017-08-07T21:45:14.881352+00:00 app[web.1]:
2017-08-07T21:45:14.881351+00:00 app[web.1]: > node app.js
2017-08-07T21:45:16.594550+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2017-08-07T21:45:16.594555+00:00 app[web.1]: designed for a production
environment, as it will leak
2017-08-07T21:45:16.594556+00:00 app[web.1]: memory, and will not scale past a single process.
2017-08-07T21:45:16.610398+00:00 app[web.1]: (node:17) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use `openUri()` instead, or set the `useMongoClient` option if using `connect()` or `createConnection()`. See http://mongoosejs.com/docs/connections.html#use-mongo-client
2017-08-07T21:45:16.612243+00:00 app[web.1]: The Yelp Camp Server is up!
2017-08-07T21:45:16.665653+00:00 app[web.1]: Db.prototype.authenticate method will no longer be available in the next major release 3.x as MongoDB 3.6 will only allow auth against users in the admin db and will no longer allow multiple credentials on a socket. Please authenticate using MongoClient.connect with auth credentials.
2017-08-07T21:45:16.914410+00:00 heroku[web.1]: State changed from starting to up
2017-08-07T21:54:00.075655+00:00 app[api]: Starting process with command `ls` by user lao_tabudlong@yahoo.com
2017-08-07T21:54:03.051279+00:00 heroku[run.4055]: Awaiting client
2017-08-07T21:54:03.090885+00:00 heroku[run.4055]: Starting process with command `ls`
2017-08-07T21:54:03.268924+00:00 heroku[run.4055]: State changed from starting to up
2017-08-07T21:54:08.289699+00:00 heroku[run.4055]: Process exited with status 0
2017-08-07T21:54:08.303853+00:00 heroku[run.4055]: State changed from up to complete
2017-08-07T22:16:51.093190+00:00 heroku[web.1]: Idling
2017-08-07T22:16:51.093810+00:00 heroku[web.1]: State changed from up to down
2017-08-07T22:16:52.026960+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-08-07T22:16:52.187881+00:00 heroku[web.1]: Process exited with status 143
2017-08-07T22:38:33.000000+00:00 app[api]: Build started by user lao_tabudlong@yahoo.com
2017-08-07T22:38:44.152229+00:00 heroku[web.1]: State changed from down to starting
2017-08-07T22:38:43.802847+00:00 app[api]: Deploy 8174904f by user lao_tabudlong@yahoo.com
2017-08-07T22:38:43.802847+00:00 app[api]: Release v5 created by user lao_tabudlong@yahoo.com
2017-08-07T22:38:33.000000+00:00 app[api]: Build succeeded
2017-08-07T22:38:45.764651+00:00 heroku[web.1]: Starting process with command `npm start`
2017-08-07T22:38:48.251552+00:00 app[web.1]:
2017-08-07T22:38:48.251586+00:00 app[web.1]: > yelpcamp@1.0.0 start /app
2017-08-07T22:38:48.251586+00:00 app[web.1]: > node app.js
2017-08-07T22:38:48.251587+00:00 app[web.1]:
2017-08-07T22:38:49.001981+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2017-08-07T22:38:49.001994+00:00 app[web.1]: designed for a production environment, as it will leak
2017-08-07T22:38:49.001995+00:00 app[web.1]: memory, and will not scale past a single process.
2017-08-07T22:38:49.018239+00:00 app[web.1]: (node:17) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use `openUri()` instead, or set the `useMongoClient` option if using `connect()` or `createConnection()`. See http://mongoosejs.com/docs/connections.html#use-mongo-client
2017-08-07T22:38:49.020061+00:00 app[web.1]: The Yelp Camp Server is up!
2017-08-07T22:38:49.043200+00:00 app[web.1]: Db.prototype.authenticate method will no longer be available in the next major release 3.x as MongoDB 3.6 will only allow auth against users in the admin db and will no longer allow multiple credentials on a socket. Please authenticate using MongoClient.connect with auth credentials.
2017-08-07T22:38:49.214038+00:00 heroku[web.1]: State changed from starting to up
2017-08-07T23:10:56.925104+00:00 heroku[web.1]: Idling
2017-08-07T23:10:56.925706+00:00 heroku[web.1]: State changed from up to down
2017-08-07T23:10:58.007504+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-08-07T23:10:58.359969+00:00 heroku[web.1]: Process exited with status 143
2017-08-08T04:47:35.000000+00:00 app[api]: Build started by user lao_tabudlong@yahoo.com
2017-08-08T04:47:45.285929+00:00 heroku[web.1]: State changed from down to starting
2017-08-08T04:47:35.000000+00:00 app[api]: Build succeeded
2017-08-08T04:47:45.069248+00:00 app[api]: Release v6 created by user lao_tabudlong@yahoo.com
2017-08-08T04:47:45.069248+00:00 app[api]: Deploy f14ef4fc by user lao_tabudlong@yahoo.com
2017-08-08T04:47:46.628278+00:00 heroku[web.1]: Starting process with command `npm start`
2017-08-08T04:47:48.774464+00:00 app[web.1]:
2017-08-08T04:47:48.774484+00:00 app[web.1]: > yelpcamp@1.0.0 start /app
2017-08-08T04:47:48.774485+00:00 app[web.1]: > node app.js
2017-08-08T04:47:48.774486+00:00 app[web.1]:
2017-08-08T04:47:49.444240+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2017-08-08T04:47:49.444256+00:00 app[web.1]: designed for a production environment, as it will leak
2017-08-08T04:47:49.444256+00:00 app[web.1]: memory, and will not scale past a single process.
2017-08-08T04:47:49.454406+00:00 app[web.1]: (node:17) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use `openUri()` instead, or set the `useMongoClient` option if using `connect()` or `createConnection()`. See http://mongoosejs.com/docs/connections.html#use-mongo-client
2017-08-08T04:47:49.455893+00:00 app[web.1]: The Yelp Camp Server is up!
2017-08-08T04:47:49.472576+00:00 app[web.1]: Db.prototype.authenticate method will no longer be available in the next major release 3.x as MongoDB 3.6 will only allow auth against users in the admin db and will no longer allow multiple credentials on a socket. Please authenticate using MongoClient.connect with auth credentials.
2017-08-08T04:47:49.919585+00:00 heroku[web.1]: State changed from starting to up
2017-08-08T05:21:42.640479+00:00 heroku[web.1]: Idling
2017-08-08T05:21:42.641117+00:00 heroku[web.1]: State changed from up to down
2017-08-08T05:21:43.112034+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-08-08T05:21:43.397138+00:00 heroku[web.1]: Process exited with status 143
2017-08-08T05:35:24.000000+00:00 app[api]: Build started by user lao_tabudlong@yahoo.com
2017-08-08T05:35:34.046061+00:00 app[api]: Release v7 created by user lao_tabudlong@yahoo.com
2017-08-08T05:35:34.046061+00:00 app[api]: Deploy 52579a31 by user lao_tabudlong@yahoo.com
2017-08-08T05:35:34.347211+00:00 heroku[web.1]: State changed from down to starting
2017-08-08T05:35:24.000000+00:00 app[api]: Build succeeded
2017-08-08T05:35:36.040512+00:00 heroku[web.1]: Starting process with command `npm start`
2017-08-08T05:35:38.881422+00:00 app[web.1]:
2017-08-08T05:35:38.881446+00:00 app[web.1]: > yelpcamp@1.0.0 start /app
2017-08-08T05:35:38.881447+00:00 app[web.1]: > node app.js
2017-08-08T05:35:38.881448+00:00 app[web.1]:
2017-08-08T05:35:39.981312+00:00 heroku[web.1]: State changed from starting to up
2017-08-08T05:35:39.914694+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2017-08-08T05:35:39.914717+00:00 app[web.1]: designed for a production environment, as it will leak
2017-08-08T05:35:39.914718+00:00 app[web.1]: memory, and will not scale past a single process.
2017-08-08T05:35:39.932988+00:00 app[web.1]: (node:17) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use `openUri()` instead, or set the `useMongoClient` option if using `connect()` or `createConnection()`. See http://mongoosejs.com/docs/connections.html#use-mongo-client
2017-08-08T05:35:39.935319+00:00 app[web.1]: The Yelp Camp Server is up!
2017-08-08T05:35:39.967512+00:00 app[web.1]: Db.prototype.authenticate method will no longer be available in the next major release 3.x as MongoDB 3.6 will only allow auth against users in the admin db and will no longer allow multiple credentials on a socket. Please authenticate using MongoClient.connect with auth credentials.
2017-08-08T05:49:20.000000+00:00 app[api]: Build started by user lao_tabudlong@yahoo.com
2017-08-08T05:49:31.423119+00:00 heroku[web.1]: Restarting
2017-08-08T05:49:31.425641+00:00 heroku[web.1]: State changed from up to starting
2017-08-08T05:49:31.128129+00:00 app[api]: Deploy 98890a0e by user lao_tabudlong@yahoo.com
2017-08-08T05:49:31.128129+00:00 app[api]: Release v8 created by user lao_tabudlong@yahoo.com
2017-08-08T05:49:32.024642+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-08-08T05:49:32.234319+00:00 heroku[web.1]: Process exited with status 143
2017-08-08T05:49:20.000000+00:00 app[api]: Build succeeded
2017-08-08T05:49:33.865572+00:00 heroku[web.1]: Starting process with command `npm start`
2017-08-08T05:49:36.912525+00:00 app[web.1]:
2017-08-08T05:49:36.912549+00:00 app[web.1]: > yelpcamp@1.0.0 start /app
2017-08-08T05:49:36.912550+00:00 app[web.1]: > node app.js
2017-08-08T05:49:36.912550+00:00 app[web.1]: `enter code here`
2017-08-08T05:49:38.250325+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2017-08-08T05:49:38.250352+00:00 app[web.1]: designed for a production environment, as it will leak
2017-08-08T05:49:38.250353+00:00 app[web.1]: memory, and will not scale past a single process.
2017-08-08T05:49:38.270747+00:00 app[web.1]: (node:17) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use `openUri()` instead, or set the `useMongoClient` option if using `connect()` or `createConnection()`. See http://mongoosejs.com/docs/connections.html#use-mongo-client
2017-08-08T05:49:38.273329+00:00 app[web.1]: The Yelp Camp Server is up!
2017-08-08T05:49:38.314596+00:00 app[web.1]: Db.prototype.authenticate method will no longer be available in the next major release 3.x as MongoDB 3.6 will only allow auth against users in the admin db and will no longer allow multiple credentials on a socket. Please authenticate using MongoClient.connect with auth credentials.
2017-08-08T05:49:38.342241+00:00 heroku[web.1]: State changed from starting to up
【问题讨论】:
您可能访问的是git.heroku.com/your-app-name.git 而不是your-app-name.herokuapp.com 【参考方案1】:来自 webdevbootcamp 视频上的问答:
“确保您尝试访问打印到控制台的正确链接。您不应尝试加载以 .git 结尾的链接,因为这只是存储库位置。
您的链接应类似于https://your-app-name.herokuapp.com/"
【讨论】:
【参考方案2】:当您使用错误的链接时,这个问题就会出现
你的链接应该是https://test-name.herokuapp.com/
【讨论】:
【参考方案3】:我遇到了同样的问题。检查您的网址,您可能会打开以.git
结尾的网址。而是转到您的 heroku 仪表板并使用正确的 url 从那里打开应用程序。
【讨论】:
【参考方案4】:参考马特的回答:-
即使部署成功,但你还没有定义网页应该是什么样子的html,那么你会得到'Method not allowed',意思是, “https://your-app-name.herokuapp.com/”将具有“不允许的方法”。
但是有一种方法可以测试部署是否正常并且您收到响应 200。
打开 jupyter notebook 并运行: 参考:https://towardsdatascience.com/create-an-api-to-deploy-machine-learning-models-using-flask-and-heroku-67a011800c50
简而言之:
import requests
import json
# local url
url = 'https://your-app.herokuapp.com/'
# sample data
data = 'Pclass': 3
, 'Age': 2
, 'SibSp': 1
, 'Fare': 50
data = json.dumps(data)
send_request = requests.post(url, data) #should get : Response 200
print(send_request.json())# should get predicted result
【讨论】:
【参考方案5】:我在 heroku 上部署 golang 网络应用程序时遇到了同样的问题。问题的根本原因在于我如何构建 url。 heroku 生成的 url 包含一个尾随的“/”,我将 url 构造为“heroku_url”+“/login”,这导致了 heroku_url//login,尝试从 heroku_url 或您的路线中删除 / 并试一试。
【讨论】:
【参考方案6】:在部署您的应用之前,请确保您的项目位于主分支上。
参考:Git Branches。
【讨论】:
以上是关于heroku 给了我不允许的方法的主要内容,如果未能解决你的问题,请参考以下文章
Heroku 在尝试打开我的网络应用程序时给了我一个 503,在本地主机上工作
GetEnumerator().Current 在主函数中调用时给了我一个异常
将 Node.js 应用程序部署到 Heroku 的应用程序错误