[英]Heroku Custom Domain Not Working
What is the correct way to connect a Heroku app with a custom domain?将 Heroku 应用程序与自定义域连接的正确方法是什么?
This is how I did it in the past:这就是我过去的做法:
Point Godaddy's DNS to heroku's provided target (example: https://peaceful-escarpment-22825.herokuapp.com )将 Godaddy 的 DNS 指向 heroku 提供的目标(例如: https://peaceful-escarpment-22825.herokuapp.com )
Turn on domain forwarding on the domain在域上开启域转发
Add domain to Heroku in the settings在设置中添加域名为Heroku
For some reason now my provided target from Heroku is like this: mycustomdomain.com.herokudns.com.出于某种原因,现在我从 Heroku 提供的目标是这样的:mycustomdomain.com.herokudns.com。 When I add that DNS to GoDaddy I get a There's nothing here, yet.
当我将 DNS 添加到 GoDaddy 时,我得到了这里什么都没有。 page.
页。
Where am I going wrong?我哪里错了? Thanks!
谢谢!
I kept skipping this step because the custom domain already showed up in my Heroku app.我一直跳过这一步,因为自定义域已经出现在我的 Heroku 应用程序中。 Ran this and it started working.
运行这个,它开始工作。
heroku domains:add www.yourwebsite.com
Bonus: Want every page to be secure SSL?奖励:希望每个页面都是安全的 SSL? Use this awesome NPM package https://www.npmjs.com/package/force-ssl-heroku
使用这个很棒的 NPM 包https://www.npmjs.com/package/force-ssl-heroku
This worked for me, but I had to include --app <app name>
at end of the command.这对我
--app <app name>
,但我必须在命令末尾包含--app <app name>
。 Like this:像这样:
heroku domains:add www.yourwebsite.com --app <app name>
For the app name, it is the app name you used when creating the app in Heroku.对于应用程序名称,它是您在 Heroku 中创建应用程序时使用的应用程序名称。
FIXED,: After struggling for a long time setting up my www domain with my Heroku app, I had to point the domain to Cloudflare then set it up as follows:已修复:在使用我的 Heroku 应用程序设置我的 www 域很长时间后,我不得不将该域指向 Cloudflare,然后按如下方式进行设置:
[1]: https://i.stack.imgur.com/o6CJc.png . [1]: https://i.stack.imgur.com/o6CJc.png 。 [2]: https://i.stack.imgur.com/P8PSQ.png .
[2]: https://i.stack.imgur.com/P8PSQ.png 。 [3]: https://i.stack.imgur.com/BB0DI.png .
[3]: https://i.stack.imgur.com/BB0DI.png 。
Then everything just works perfectly both NON-WWW and WWW domains.然后一切都可以在非 WWW 和 WWW 域中完美运行。
I did not need to do any URL forwarding as see bellow我不需要做任何 URL 转发,如下所示
[4]: https://i.stack.imgur.com/wgMit.png . [4]: https://i.stack.imgur.com/wgMit.png 。
Heroku domains:add www.yourwebsite.com --app <app name>
这是最好的方法,因为它需要知道要指向哪个特定的应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.