簡體   English   中英

當我打開 heroku 時,我遇到了帶有 h10 代碼的 Strapi 問題

[英]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

我的 procfile 我不知道沒關系

web:節點配置/環境/生產/服務器。json

https://strapi.io/documentation/3.0.0-beta.x/migration-guide/migration-guide-beta.19-to-beta.19.4.html#listened-host-changed

因為 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.

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