How to redirect subscriber confirmation to Gatsby/Netlify from Heroku

Everything seems to be in order: webhooks, Gatsby plugins, Mailgun, etc. However, whenever a new user subscribes to my site, the confirmation email link takes them to the Heroku app that’s hosting my Ghost admin. If possible, I’d like the user to be redirected to my root domain so that they’re not exposed to the Heroku backend. I’ve marked the Heroku site as private so that the Gatsby setup is truly “headless”. The user hits a login screen, which is bad.

Do you know how to redirect subscriber confirmation to Gatsby/Netlify from Heroku? Thanks in advance! Diagnostic details below:


Read about Ghost redirections here - Tutorial: Implementing redirects in Ghost

1 Like

Thanks! That was helpful. However, I’m still not seeing the desired behavior. My redirects.json file looks like this:

[{
     "from": "^/members/(.*)$",
     "to": "https://luisvargas.pw/",
     "permanent": true
 }]

With this file, https://ghost-v4-luisvargasio.herokuapp.com/members/ successfully redirects to https://luisvargas.pw/, but whenever there is a ?token= parameter in the /members/ URL, I’m taken to the private Heroku site. How would I account for this scenario while still passing the confirmation token to the backend?

I got it to work. I updated the redirects.json file to:

[{
     "from": "^/(.*)$",
     "to": "https://luisvargas.pw/",
     "permanent": true
 }]

@thelovekesh, is there a way to mask the URL in the email template? The email includes the following:

You can also copy & paste this URL into your browser:

https://ghost-v4-luisvargasio.herokuapp.com/members/?token=ABCDE12345&action=subscribe

I found this thread helpful. I need to update subscribe.js. But, this file does not appear when I download the Heroku repo. It seems that I cannot edit the core Ghost application files.

Actually in the code repo Ghost is added as a dependency so Heroku downloads the Ghost CMS during the deployment(you will see in logs when Heroku downloads dependencies). You cant change this thing till it is added to the dependency.
You can try downloading the Ghost core and edit the suitable parts and then deploy it to Heroku(I didn’t try it yet).

How would I download the Ghost core? Do you mean install Ghost using the Ghost-CLI in the same directory where I cloned the Heroku repo?

You can download the Ghost core from the GitHub releases. Installing Ghost from Ghost CLI in repo doesn’t work here because it’s not in the structure that can be deployed to Heroku.

1 Like