skip to Main Content

I am currently developing an angular 9 website. I wanted to integrate Telegram Login to my website. I have done all the necessary steps to include it to the website. I have configured the domain name setting of the bot to my own. When deployed and in production, the website works perfectly well.

The problem arises when I try and debug it locally, the button raises “bot domain invalid” error. I am aware that this is because the website isn’t hosted in the domain name the bot is configured to handle.

Solutions that I’ve tried using are

  • Use ngrok to proxy localhost to a public URL and set that as the bot’s domain. This for some reason, which eludes me, won’t work.
  • Since I’m developing in a windows environment, configure hosts file in windows to point my main domain name to localhost. This also hasn’t worked, mysteriously.

Is there any other solutions that I can use to aid my use case?

I understand that I might not have implemented the solutions I mentioned above correctly. I will also appreciate it if I could get some decent pointers in those areas.

3

Answers


  1. Telegram login requires https so you need to host your angular using the –ssl option
    Also as you mentioned above to trick the domain check you also have to set the –host option to the same name as specified in your hosts file.

    Let’s say the domain is example.com

    When serving with angular
    ng serve –ssl –host example.com –port 443

    And add example.com to your hosts file

    Login or Signup to reply.
  2. You can test the telegram login widget locally if you:

    1. host your application on port 80
    2. access it with http://127.0.0.1 and not http://localhost

    Check this link for details.

    Login or Signup to reply.
  3. I’m a bit late to the party, but for anyone looking for a more elegant solution (and not dependent on ng-serve), you can use a tunnelling service. Some examples are:

    With these tunnels you essentially create a valid domain for your bot. All you need to do is set that value on bot father while developing.

    It is worth noting that once your bot is live, you will no longer be able to test this locally, but it allows you to create another "staging" bot that you can use locally whenever you want, leaving the production bot live and untouched.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search