🐛 Fix routing

main
Vincent ASTOLFI 9 months ago
parent 056c90aeef
commit ed961b8f6e

@ -26,7 +26,7 @@ app.get('/', (req, res) => {
})
app.get('/scoreboard', (req, res) => {
return res.sendFile(path.normalize(path.join(__dirname, 'public/pages/scoreboardView.html')))
return res.sendFile(path.normalize(path.join(__dirname, '/public/pages/scoreboardView.html')))
})
app.get('/register', (req, res) => {
@ -143,6 +143,7 @@ app.get('/user-info', (req, res) => {
return res.json(results[0]);
});
} catch (ex) {
console.log(ex)
return res.status(400).send('Invalid token.');
}
});

@ -85,7 +85,7 @@
<p id="playerInfo"></p>
<a href="/scorebaord">
<a href="/scoreboard">
see scorebaord
</a>

@ -73,19 +73,10 @@ socket.on('opponent left', () => {
modal.style.display = 'block';
})
function deleteCookie(name) {
document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
socket.on("go to menu", () => {
goToMenu()
})
socket.on("disconnect", () => {
deleteCookie('authToken');
window.location.href = "/"
});
// #region rematch handling
socket.on("ask for rematch", () => {

@ -1,7 +1,3 @@
function deleteCookie(name) {
document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
document.addEventListener('DOMContentLoaded', async () => {
const playerInfoDiv = document.getElementById('playerInfo');
@ -14,10 +10,8 @@ document.addEventListener('DOMContentLoaded', async () => {
});
if (response.status === 401) {
deleteCookie('authToken');
window.location.href = '/';
} else if (!response.ok) {
deleteCookie('authToken');
playerInfoDiv.textContent = 'Error: Could not retrieve user information.';
window.location.href = '/';
} else {

Loading…
Cancel
Save