LoginSignup
32
34

More than 3 years have passed since last update.

herokuのアプリ名(URL)変更方法【10秒でできる】

Posted at

アプリを作成しwebに公開する時、手軽さからherokuを用いる方は多いのではないでしょうか。
ただ、デフォルトで生成されるアプリ名って、ランダムな英語でちょっと覚えにくいです。

例.
$ heroku create
Creating app... done, fathomless-beyond-39164
https://damp-fortress-5769.herokuapp.com/ 
https://git.heroku.com/damp-fortress-5769.git

せっかく自分が作成したアプリなんだし、オリジナルな名前を付けてあげたいですよね?
そこでこの記事では、herokuのアプリ名とURLにオリジナルな文字列を設定する方法をご紹介します。

前提条件

この記事で紹介する方法は以下を行っていることが条件となっています。

  • heroku CLIがインストール済でコマンドライン上でherokuコマンドが使えること
  • $ heroku createしており、アドレスが生成されていること

方法

すごく簡単です。
コマンドラインで以下を実行します。

$ heroku apps:rename hogehoge

すると以下の実行結果が表示されると思います。

Renaming damp-fortress-5769 to hogehoge... done
https://hogehoge.herokuapp.com/ | https://git.heroku.com/hogehoge.git
Git remote heroku updated
 ▸    Don't forget to update git remotes for all other local checkouts of the app.

アプリ名がhogehogeに変更され、URLもhttps://hogehoge.herokuapp.com/に変更されています。
更にgitのリモート設定もhttps://git.heroku.com/hogehoge.gitに自動的に更新されています。

もちろん以前のURLではアクセスできません。
image.png

herokuサイトからも変更可能(ただしgitリモートは変わらない)

herokuのユーザーページからもアプリ名の変更が可能ですが、このときgitのリモートは変更されないので注意が必要です。
その際は、以下のコマンドでgitのリモート設定も変更しましょう。

$ git remote rm heroku
$ heroku git:remote -a hogehoge

参考になった記事・サイト

【herokuコマンド】アプリ名変更
Herokuのアプリ名を変更する + Gitリモート設定変更

32
34
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
32
34