簡體   English   中英

部署Next.js項目到Heroku失敗

[英]Deploying Next.js Project to Heroku Failure

我正在嘗試在 heroku 上部署我的 next.js 項目,但在應用程序運行時,它失敗了,這是失敗的日志。

2019-11-17T18:23:33.067077+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pens-nextjs.herokuapp.com request_id=f01abc4b-bf9b-4f2e-8b8e-06184580bfc8 fwd="41.232.85.202" dyno= connect= service= status=503 bytes= protocol=https
2019-11-17T18:23:37.203987+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pens-nextjs.herokuapp.com request_id=f4f94391-c79c-4503-9751-fe8a6c5461d3 fwd="41.232.85.202" dyno= connect= service= status=503 bytes= protocol=https
2019-11-17T18:23:38.045712+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=pens-nextjs.herokuapp.com request_id=98cc2b80-5631-4af1-9889-26abecca6aec fwd="41.232.85.202" dyno= connect= service= status=503 bytes= protocol=https

我也面臨同樣的問題。 我在 NextJs 應用程序的公共文件夾中添加了 favicon.ico。 此外,在 package.json 中添加以下行

"scripts": {
  "dev": "next",
  "build": "next build",
  "start": "next start -p $PORT",
  "heroku-postbuild": "npm run build",
  "test": "echo \"Error: no test specified\" && exit 1"
},

希望這對你有用!

Next.js 默認綁定到端口 3000,而 Heroku 期望您的服務器進程綁定到PORT環境變量中提供的端口。 您可以通過將package.json修改為"start": "next start -p $PORT"使 Next.js 服務器綁定到此端口。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM