auth: Broken Invitation Links - http://kong is the domain

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

Currently, when sending an invitation to a user, the invitation link in the email is http://kong/auth/v1/verify?token=xxx rather than the proper domain.

To Reproduce

Steps to reproduce the behaviour, please provide code snippets or a repository:

  1. Setup docker Supabase
  2. Go to the authentication
  3. Click “Add user”
  4. Select “Send Invitation”
  5. Check the invitation link in the email

Expected behaviour

It was expected that the invitation URL to contain the configured URLs in the .env file rather than http://kong as the domain.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 15
  • Comments: 49 (6 by maintainers)

Commits related to this issue

Most upvoted comments

This was bugging me hard. So I added a force no-change environment variable and submitted a PR.

With the changes:

  1. Set API_EXTERNAL_URL environment variable as you normally would.
  2. Add a new environment variable API_FORCE_EXTERNAL_URL to equal true.

.env:

API_EXTERNAL_URL=https://sb.mydomain.com/auth/v1
API_FORCE_EXTERNAL_URL=true

Kubernetes:

  environment:
    API_EXTERNAL_URL: https://sb.mydomain.com/auth/v1
    API_FORCE_EXTERNAL_URL: "true"

Fix repo: nickmitchko/auth Fix container (latest): nickmitchko/gotrue:latest Fix PR: #1571

@Vokturz, @Chipsnet, @hf

I’m not sure if anyone has realized but in the docker-compose.yml it states SUPABASE_URL: http://kong/ changing this to use the API_EXTERNAL_URL variable should solve your issue. Or so one would think I have changed it to the local ip and i am getting it in the email link but I don’t get the port. Which in my case is 8000 the api is supposed to be directed too.

hi everyone, we fixed this issue recently by specifying a new config param - GOTRUE_MAILER_EXTERNAL_HOSTS which specifies the list of hosts that can be used. If this is empty, it will just default to use the API_EXTERNAL_URL

this is somewhat similar to the suggestion @nickmitchko proposed but we’re solving it with an allow list rather than a flag to disable it

MAILER_URLPATHS_CONFIRMATION=“${API_EXTERNAL_URL}/auth/v1/verify” MAILER_URLPATHS_INVITE=“${API_EXTERNAL_URL}/auth/v1/verify” MAILER_URLPATHS_RECOVERY=“${API_EXTERNAL_URL}/auth/v1/verify” MAILER_URLPATHS_EMAIL_CHANGE=“${API_EXTERNAL_URL}/auth/v1/verify”

this works

I’m facing the same problem. My temporary fix is to switch to “supabase/gotrue:v2.67.0” in my docker-compose.yml

There is some breaking change in a minor release: v2.67.1 (https://github.com/supabase/gotrue/compare/v2.67.0...v2.67.1).

In our case, after upgrading Docker image to anything above v2.67.1 (including current latest) turns the account confirmation URL from https to https, there are also some other minor changes.

v2.67.0 (correct)

https://auth.domain.app/auth/v1/verify?token=token&type=signup&redirect_to=https://web.domain.app/login

v2.67.1 (broken)

http://auth.domain.app/auth/v1/verify?redirect_to=https%3A%2F%2Fweb.domain.app%2Flogin&token=token&type=signup

I’ve tried to reproduce this outside of the docker environment, kong etc. by injecting our configuration through .env, so I can run the debugger on main.go. I’ve set up breakpoints on: ConfirmationMail and isValidExternalHost and problem doesn’t exist for some reason.

Unfortunately I don’t have much time currently to add some additional logging to the code, compile the binary and debug/run it from the Docker context, to understand at which stage the URL does get broken.

I am experiencing a similar issue with the storage API, createSignedUrl in the js SDK is returning a URL with kong:8000 as the domain.

In the docker-compose.yml file there is a line SUPABASE_URL: http://kong Replace that with your project’s URL, then stop and create the containers again:

// Stop and remove the containers
docker compose down

//Recreate and start the containers
docker compose up -d

This worked for me and the Invite emails are now giving the correct link.

@Obeyed just tested again on latest supabase version 1.25.03, adding GOTRUE_MAILER_EXTERNAL_HOST get rid of the error. So was probably a problem with the version i was trying to deploy. The noop part was a misnamed env var for the smtp host. Mail are finally being sent ! Thanks for your help

Trying to selfhost on latest version of supabase, and still getting this error whatever the value is set in my docker-compose.yml file env settings. Can we please have some guidance on how to pass correct settings to gotrue from the supabase docker-compose file ?

Check my repo for the changes I made and build your own fork. IMO the change that introduced this issue was bad logic that can easily be changed.

Ps, I don’t update the fork nickmitchko/auth.

However, this means that STUDIO will attempt to access kong from the outside

For security reasons, it is recommended that studio access kong from within the docker container

While helpful in the short term, this problem needs to be fixed in the long term.

Hi @Obeyed, I am not sure if I can help here. In our case we’re running fork with a couple amendments. Most importantly this line needs changing: https://github.com/supabase/gotrue/commit/c1f0ec8da6e8c19361789cb3d182a4c77c2763e5#diff-97dfc3310e5139b4d9c7a160bd077aeb81ca1e7b8d7cfa837a402f54b4c03a3dR213

Given that Supabase team is likely busy with other items your best bet is either to wait or apply it yourself and build a Docker image, alternatively use our build: s3drive/gotrue:v2.129.1 (https://hub.docker.com/layers/s3drive/gotrue/v2.129.1/images/sha256-a8176564a48f34b20598884848f284ed78cb8db0b5d44fea20d2ed8d37a4eab9?context=explore) which is the most recent Supabase version with these two fixes applied: https://github.com/supabase/gotrue/compare/master...tomekit:gotrue:master however please be aware that you shouldn’t really use unofficial images for your organization… after all it’s auth.

Good luck !