Panel serve with prefix and basic login page

Hi all,
I tried to serve a Panel app with basic authentication as described here. The problem is when I added a prefix to the URL, that specifies what the app is about, e.g., chat

panel serve app.py --basic-auth credentials.json --cookie-secret topsecret --prefix=chat

Unfortunately, when I try to open localhost:5006/chat/ , then the page redirects to http://localhost:5006/login?next=%2Fchat%2F and then I cannot access the login page anymore. I solved it by updating the URL like: http://localhost:5006/chat/login?next=%2Fchat%2F. I had to also update the login-template’s Form URL to /chat/login

But then after login, again it tried to access: localhost:5006/, which I had to again edit and make it localhost:5006/chat to make it work. Is there anything I can do in the serve command that the prefix is respected for the login?