"Accept the Invite" link always redirects to the home page

Whenever I invite a user, the user would get an email with the link “Accept the Invite” that would supposedly redirects him to a page that allows him to create his password.

However, what happens instead is that the user gets redirected to the home page and thus, cannot create a password and log into the CMS.

I noticed that the invite token will be written in the URL and would look like this:
https://natural-patterns[DOT]netlify[DOT]app/#invite_token=wf6zu23Bcihb3cNtrltBqQ

When I add an “admin” segment to the URL, the page correctly directs the user to the page that allows him to create the password.

site:https://natural-patterns.netlify.app/**admin**/#invite_token=wf6zu23Bcihb3cNtrltBqQ

The same issue happens with the password recovery link.

Here is the website:

I used Astro framework to build the site.

I have followed the documentation in setting up the CMS such as adding the following to the homepage:

<script src="https://identity.netlify.com/v1/netlify-identity-widget.js"></script>

<script>
  if (window.netlifyIdentity) {
    window.netlifyIdentity.on("init", user => {
      if (!user) {
        window.netlifyIdentity.on("login", () => {
          document.location.href = "/admin/";
        });
      }
    });
  }
</script>

I would appreciate it if someone knows the solution to resolve this issue.

You should add the identity widget on the home page as well so it can handle the recovery and invite OR change the templates: Identity-generated emails | Netlify Docs