I was trying to get res.status.json as an alert, but what I could only get was this;

this is my Server join.js
const express = require('express');
const mongoose = require('../mongoose/index');
const router = express.Router();
const Customer = require("../mongoose/schemas/customers");
const crypto = require('crypto');
mongoose.connect();
router.get("/", function (req, res,) {
fs.readFile("./views/join.html", (err, data) => {
if (err) {
res.send("error");
} else {
res.writeHead(200, { "Content-Type": "text/html" });
res.write(data);
res.end();
}
});
});
//Check duplicated id
router.post('/duplicated', async (req, res) => {
try {
const { userid } = req.body;
const existingUser = await Customer.findOne({ userid });
if (existingUser) {
return res.json({ exists: true });
} else {
return res.json({ exists: false });
}
} catch (error) {
console.error(error);
return res.status(500).json({ message: 'Server Error' });
}
});
// Registeration
router.post("/", async (req, res) => {
try {
const { userid, userpw } = req.body;
const hashedPassword = crypto.createHash('sha512').update(userpw).digest('hex');
const newCustomer = new Customer({ userid, userpw:hashedPassword });
await newCustomer.save();
return res.status(201).json({ message: 'Join Completed' });
//res.status(201).redirect("/login");
} catch (error) {
console.error(error);
res.status(500).json({ message: "Server Error" });
}
});
module.exports = router;
and this is my client join.js
const userid = document.querySelector("#userid"),
userpw = document.querySelector("#userpw"),
userpwc = document.querySelector("#userpwc"),
matchMessage = document.getElementById('password-match-message'),
registrationButton = document.querySelector("#SignupButton"),
idCheck = document.querySelector("#idcheck"),
userIdWarning = document.querySelector("#userIdWarning");
userpwc.addEventListener('input', confirmpw);
idCheck.addEventListener("click", checkDuplicateID);
//Registration
async function register(){
const newUserId = userid.value;
const newPassword = userpw.value;
const newPasswordc = userpwc.value;
try {
// 회원가입 요청
const response = await fetch('/join', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
userid: newUserId,
userpw: newPassword
})
});
const data = await response.json();
console.log(data);
console.log(data.message);
if (data.message === 'Join Completed') {
alert(data.message);
setTimeout(function() {
window.location.href = "/login";
}, 5000);
} else {
// if join failed
console.error('Login Failed:', data.message);
}
} catch (error) {
console.error('Error:', error);
}
}
// check pw
function confirmpw() {
let value1 = userpw.value;
let value2 = userpwc.value;
if (value2 !== "") {
if (value1 === value2) {
matchMessage.textContent = "Match";
matchMessage.style.color = "#4caf50";
} else {
matchMessage.textContent = "Doesn't Match";
matchMessage.style.color = "#f44336";
}
} else {
matchMessage.textContent = "";
};
}
function checkDuplicateID() {
const newUserId = userid.value;
const regexs = /^(?=.*[a-zA-Z])[a-zA-Z0-9]{1,}$/;
if (!newUserId) {
idCheck.innerText = "Type your id";
return;
}
if (!regexs.test(newUserId)) {
idCheck.innerText = "Invalid id";
return;
}
// check duplicated id
fetch('/join/duplicated', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ userid: newUserId })
})
.then(response => response.json())
.then(data => {
const userIdWarning = document.getElementById('userIdWarning');
// if duplicated
if (data.exists) {
userIdWarning.innerText = "Unavailable ID";
registrationButton.disabled = true;
} else {
userIdWarning.innerText = "Available ID";
// not duplicated
registrationButton.disabled = false;
}
})
.catch(error => {
console.error('Error:', error);
});
}
plus, I could make endpoint of fetch(‘/join/duplicated’, by the way, it was impossible to make endpoint of /join/register. When I tried to Post registeration by fetch(‘/join/register’, and then console printed POST join/404

Thank you.