Basically, we don't need to use Heroku for static website recently since we can use GitHub, Netlify, Vercel, and so on.
However, if we want to use basic auth for a website, we will need some extra work. It might be worth of trying, but if you just want to upload a couple of HTML and CSS files, that work will be too much.
Step1. Create a website
Step2. Download or Clone a repo
Step3. Login Heroku via terminal and create an app
Step4. Push your website to Heroku
Step5. Set info for Basic Auth
In terms of step1, it depends on you, so I will skip this part 😜
Step2 Download or Clone a repo
Go to the following repo and download repo or clone repo.
You need to move all step1 fills into public and run the following commands.
$ git add .# you can type anything you want as a comment.$ git commit -m'initial commit'
Step3 Login Heroku via terminal and create an app
$ heroku login
# If you skip your site name, Heroku generates a new name for you$ heroku create your-site-name
Step4 Push your website to Heroku and check it
IF you can push your site properly, heroku-cli will show you your website url on Terminal. You can use that to access your website or you can use heroku open to access the webstie.
$ git push heroku master
$ heroku open
Step5 Set info for Basic Auth
Almost there. This is the last step. We need to type 2 commands to add Basic Auth to your website.
Of course, you can set anything you want as username and password.
$ git clone https://github.com/nulltask/heroku-static-provider.git my-site
$ cd my-site
# If you use free plan and have 5 apps already, you need to delete an app to run heroku create command
$ heroku create
$ git push -u heroku master
$ heroku open
Deployment
Add or update files in /public.
$ git add .
$ git commit -a -m 'some commit message'
$ git push heroku master
$ heroku open