[英]When i open heroku i have a problem with strapi with h10 code
当我打开 heroku 并运行 heroku 日志时遇到这个问题 --tail 应用程序崩溃并且在 heroku 中看不到我的应用程序 strapi。
2020-05-04T19:05:38.602418+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=strapi-inmobiliaria-gatsby.herokuapp.com request_id=2b5c1e98-7aaf-4362-905f-bf0e17391fe0 fwd="190.244.81.129" dyno= connect= service= status=503 bytes= protocol=https 2020-05-04T19:05:38.862307+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=strapi-inmobiliaria-gatsby.herokuapp.com request_id=629c8bb2-8e68-4b8d-8d35-919c95130eb2 fwd="190.244.81.129" dyno= connect= service= status=503 bytes= protocol=https 2020-05-04T19:13:18.189908+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=strapi-inmobiliaria-gatsby.herokuapp.com request_id=cd2366d2-1851-4ed2-bf70-72d8db61c1c4 fwd="190.244.81.129" dyno= connect= service= status=503 bytes= protocol=https 2020-05-04T19:13:18.538292+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=strapi-inmobiliaria-gatsby.herokuapp.com request_id=c757b34d-7944-4a5b-944b-ae0dcb84affc fwd="190.244.81.129" dyno= connect= service= status=503 bytes= protocol=https
我搜索问题,但我不确定它是什么。
它是我的 package.json
{ "name": "bienesraices", "private": true, "version": "0.1.0", "description": "A Strapi application", "scripts": { "develop": "strapi develop", "start": "strapi start", "build": "strapi build", "strapi": "strapi" }, "devDependencies": {}, "dependencies": { "knex": "<0.20.0", "mysql": "latest", "pg": "^8.0.3", "strapi": "3.0.0-beta.20.1", "strapi-admin": "3.0.0-beta.20.1", "strapi-connector-bookshelf": "3.0.0-beta.20.1", "strapi-plugin-content-manager": "3.0.0-beta.20.1", "strapi-plugin-content-type-builder": "3.0.0-beta.20.1", "strapi-plugin-email": "3.0.0-beta.20.1", "strapi-plugin-graphql": "^3.0.0-beta.20.1", "strapi-plugin-upload": "3.0.0-beta.20.1", "strapi-plugin-users-permissions": "3.0.0-beta.20.1", "strapi-utils": "3.0.0-beta.20.1" }, "author": { "name": "A Strapi developer" }, "strapi": { "uuid": "13a8b7a9-81dc-4560-98f1-0ec0ec1769c0" }, "engines": { "node": ">=10.0.0", "npm": ">=6.0.0" }, "license": "MIT" }
Running printenv on ⬢ strapi-inmobiliaria-gatsby... up, run.3613 (Free) NODE_HOME=/app/.heroku/node NODE_ENV=production WEB_MEMORY=512 DYNO=run.3613 PWD=/app LINES=30 HOME=/app DATABASE_PORT=5432 NODE_MODULES_CACHE=false DATABASE_URL=postgres://cbf************:d0******************************@ec2-52******40.compute-1.amazonaws.com:5432/d3******ntmu PORT=42473 MEMORY_AVAILABLE=512 DATABASE_NAME=d3************mu COLUMNS=120 DATABASE_USERNAME=cbf****** WEB_CONCURRENCY=1 SHLVL=1 PATH=/app/.heroku/node/bin:/app/.heroku/yarn/bin:/usr/local/bin:/usr/bin:/bin:/app/bin:/app/node_modules/.bin
web:节点配置/环境/生产/服务器。json
因为 Heroku 期望 Strapi 在可公开访问的端口上运行,您需要在config/environments/*/server.json
中设置host
变量以使用0.0.0.0
而不是 localhost。
(Strapi Heroku 指南尚未更新)
我刚刚从strapi docs添加了自分配的SSL object,它可以工作。 按照以下步骤将行添加到database.js
文件中。
ssl: {
rejectUnauthorized: env.bool('DATABASE_SSL_SELF', false), // For self-signed certificates
},
options: {
ssl: env.bool('DATABASE_SSL', false),
}, `
完整的database.js
文件看起来像
module.exports = ({
env
}) => ({
defaultConnection: 'default',
connections: {
default: {
connector: 'bookshelf',
settings: {
client: 'postgres',
host: env('DATABASE_HOST', '127.0.0.1'),
port: env.int('DATABASE_PORT', 5432),
database: env('DATABASE_NAME', 'strapi'),
username: env('DATABASE_USERNAME', ''),
password: env('DATABASE_PASSWORD', ''),
//add this line
ssl: {
rejectUnauthorized: env.bool('DATABASE_SSL_SELF', false), // For self-signed certificates
},
},
// add this line
options: {
ssl: env.bool('DATABASE_SSL', false),
},
},
},
});
我的server.js
文件看起来像
module.exports = ({
env
}) => ({
host: env('HOST', '0.0.0.0'),
port: env.int('PORT', 1337),
admin: {
auth: {
secret: env('ADMIN_JWT_SECRET', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'),
},
},
});
也添加了这个,它现在正在工作..
ssl: {
rejectUnauthorized: env.bool('DATABASE_SSL_SELF', false), // For self-signed certificates
},
},
options: {
ssl: env.bool('DATABASE_SSL', false),
},
在.gitignore 的末尾添加以下行
封装锁.json
并删除文件
封装锁.json
它帮助了我:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.