Keycloak refersh issue for angular application in NeXT cloud environment

I am using keycloak JavaScript adapter in my Angular 11 app and whilst my login and redirection work, the problem is that whenever I refresh my ng-app it will again ask for keycloak login although I see that my session is still active on /auth/realms/{image a realm name}/account.

As I have understood it from the keycloak JS Adapter documentation https://www.keycloak.org/docs/3.0/securing_apps/topics/oidc/javascript-adapter.html, when onLoad is set to login-required for init options it authenticates the client if the user is logged-in to Keycloak or display the login page if not. But it seems like

in my case, after entering the username and password through the keycloak login page it was going to the angular web page after that when I refresh the web page it was going into the keycloak login page. Hereafter refreshing the page token was not storing.
Note: When I used the local URL it’s working fine but the problem is when I used the nextcloud -eil environment URL it’s not working fine.