heroku / heroku-buildpack-nginx

Run NGINX in a Heroku app
244 stars 787 forks source link

How do I use this with Next.js project on Heroku? #77

Closed luxplanjay closed 3 years ago

luxplanjay commented 3 years ago

Hi. I have a Next.js app which runs on NodeJS. Stumbled upon this package while searching for a way to force HTTPS when user visits HTTP route manually. For example redirect from http://mysite.com/login to https://mysite.com/login if user enters first url.

I made a config folder with a config file just like in «SSL on Heroku» example from this repo and added a buildpack on Heroku in project settings. I also made a tmp folder with app-initialized file, but do not really understand if that is enough and what it does. Here's a screenshot of project's structure https://gyazo.com/d79a69c3254c47b526f5f07d3f69f79e.

Also I changed Procfile to this. yarn start starts nextjs app in prod mode.

web: bin/start-nginx yarn start

App builds without errors and I can see that this buildpack is being used in logs. But upon visiting http route I do not get redirected to the https version of it. Please help.

PS: heroku logs also show a bund of messages between requests and I think they are about this buildpack. Here's a screenshot https://gyazo.com/ed0287773e6888351aa4f049acbf8bb4