Ah yeah we are missing this in our Heroku guide.
In your server.js (production: ./config/env/production/server.js)
You need to set the url key from here: https://strapi.io/documentation/v3.x/concepts/configurations.html#server to your Heroku app URL
In your ./config/env/production/server.js it should look something like:
module.exports = ({ env }) => ({
host: env("HOST", "0.0.0.0"),
port: env.int("PORT", 1337),
url: env("APP_URL"),
admin: {
auth: {
secret: env('ADMIN_JWT_SECRET'),
},
},
});
Then you can set the APP_URL environment variable in heroku with their CLI:
heroku config:set HEROKU_URL=$(heroku info -s | grep web_url | cut -d= -f2)
Which will be something like: http://myapp.herokuapp.com
Quick side point as I see there might some confusion as to what the env() function does in those files. I’d suggest you take a look at this: https://strapi.io/documentation/v3.x/concepts/configurations.html#casting-environment-variables
The env() function has two parameters, the first is the name of the environment variable process.env.SOME_VAR such as env('SOME_VAR') and if that process.env.SOME_VAR is undefined you pass an alternative.
So env('SOME_VAR', 'defaultValue') will read and use process.env.SOME_VAR if it exists, if it’s undefined then it will use defaultValue instead. There is no need to define the process.env.SOME_VAR manually, and if you don’t want a default value then you only need: env('SOME_VAR')