To configure an HTTP -> HTTPS redirect using NextJs on Heroku, is necessary to configure a NextJs custom server.
Here is a custom server configured with the redirect working:
const express = require('express');
const cookieParser = require("cookie-parser");
const next = require('next');