This is the code in error
//index.html
<html>
<head></head>
<body>
<div id='user'></div>
<script src="./index.js"></script>
</body>
</html>
//index.js
const id = document.getElementById('user');
fetch('/api/user')
.then((res)=>res.json)
.then((data)=>{
id.innerText = data.userid})
When you access the index page, the corresponding screen appears.
The problem is probably in your redirection/login code, not what you posted here. If you post that, maybe we could help further.