title: How do I solve "Middleware "strapi::session": App keys are required" error in my deployment of Strapi to Heroku?
body: <p>I'm following <a href="https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/deployment/hosting-guides/heroku.html" rel="noreferrer">the official instructions</a> to deploy my <a href="https://github.com/strapi/strapi-starter-next-corporate" rel="noreferrer">strapi starter app</a> to Heroku. The app runs fine locally. The only thing I left out in my deployment instructions were installing the PG node module (it is already installed because my local app uses Postgresql).</p>
  <p>Accessing the Heroku logs, I see this:</p>
  <pre><code>error: Middleware &quot;strapi::session&quot;: App keys are required. 
  Please set app.keys in config/server.js (ex: keys: ['myKeyA', 'myKeyB'])
  </code></pre>
  <p>Maybe this is an important detail: I followed this process once, and everything worked. I was able to deploy to Heroku. I tried it again and it didn't work. I was thinking maybe Heroku had a problem with me re-using an app name, but I tried to name the app something different in Heroku and I still had the same error.</p>
  <p>Is heroku looking in the wrong place for my server.js file? Should it be looking in my &quot;./config/env/production&quot; folder instead of my &quot;./config&quot; folder?</p>
  <p>Per the instructions, here is my ./config/env/production/database.js</p>
  <pre><code>const parse = require('pg-connection-string').parse;
  const config = parse(process.env.DATABASE_URL);
  
  module.exports = ({ env }) =&gt; ({
    connection: {
      client: 'postgres',
      connection: {
        host: config.host,
        port: config.port,
        database: config.database,
        user: config.user,
        password: config.password,
        ssl: {
          rejectUnauthorized: false
        },
      },
      debug: false,
    },
  });
  </code></pre>
  <p>Here is my ./config/env/production/server.js</p>
  <pre><code>module.exports = ({ env }) =&gt; ({
      url: env('MY_HEROKU_URL'),
  });
  </code></pre>
  <p>And here is my ./config/server.js</p>
  <pre><code>module.exports = ({ env }) =&gt; ({
    host: env('HOST', '0.0.0.0'),
    port: env.int('PORT', 1337),
    app: {
      keys: env.array('APP_KEYS'),
    },
  });
  </code></pre>
  <p>my package.json for good measure:</p>
  <pre><code>{
    &quot;dependencies&quot;: {
      &quot;@strapi/plugin-graphql&quot;: &quot;^4.0.0&quot;,
      &quot;@strapi/plugin-i18n&quot;: &quot;4.0.6&quot;,
      &quot;@strapi/plugin-users-permissions&quot;: &quot;4.0.6&quot;,
      &quot;@strapi/strapi&quot;: &quot;4.0.6&quot;,
      &quot;lodash.set&quot;: &quot;^4.3.2&quot;,
      &quot;pg&quot;: &quot;8.6.0&quot;,
      &quot;pg-connection-string&quot;: &quot;^2.5.0&quot;
    },
    &quot;name&quot;: &quot;backend&quot;,
    &quot;private&quot;: true,
    &quot;version&quot;: &quot;0.1.0&quot;,
    &quot;description&quot;: &quot;A Strapi application&quot;,
    &quot;scripts&quot;: {
      &quot;develop&quot;: &quot;strapi develop&quot;,
      &quot;start&quot;: &quot;strapi start&quot;,
      &quot;build&quot;: &quot;strapi build&quot;,
      &quot;strapi&quot;: &quot;strapi&quot;
    },
    &quot;devDependencies&quot;: {},
    &quot;author&quot;: {
      &quot;name&quot;: &quot;A Strapi developer&quot;
    },
    &quot;strapi&quot;: {
      &quot;uuid&quot;: &quot;f64b509e-2d95-4464-8d39-d6f0d1c7a31a&quot;,
      &quot;template&quot;: &quot;@strapi/template-corporate@^1.0.0&quot;,
      &quot;starter&quot;: &quot;@strapi/starter-next-corporate&quot;
    },
    &quot;engines&quot;: {
      &quot;node&quot;: &quot;&gt;=12.x.x &lt;=16.x.x&quot;,
      &quot;npm&quot;: &quot;&gt;=6.0.0&quot;
    },
    &quot;license&quot;: &quot;MIT&quot;
  }
  </code></pre>
  <p>I'm running Node v14.18.3 and NPM v6.14.15</p>