From d9e79fc771794df3f6a1e3565b7b4ca561fd2e38 Mon Sep 17 00:00:00 2001 From: admtracksteel Date: Mon, 20 Apr 2026 17:09:31 +0000 Subject: [PATCH] fix: Logto loop infinito callback URL exacta --- src/main.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main.js b/src/main.js index 729fdc8..d45d4d1 100644 --- a/src/main.js +++ b/src/main.js @@ -15,13 +15,18 @@ const logtoClient = new LogtoClient({ }); async function protectPage() { - const isCallback = window.location.pathname.includes('callback'); + const urlParams = new URLSearchParams(window.location.search); + const isCallback = urlParams.has('code') && urlParams.has('state'); + const exactRedirectUri = window.location.origin + '/'; + if (isCallback) { try { - await logtoClient.handleSignInCallback(window.location.href); + await logtoClient.handleSignInCallback(exactRedirectUri); window.location.assign('/'); } catch (error) { + style.remove(); + document.body.innerHTML = `

Erro de Autenticação Logto

${error.message}

`; console.error('Falha no callback do Logto:', error); } return; @@ -29,7 +34,7 @@ async function protectPage() { const isAuthenticated = await logtoClient.isAuthenticated(); if (!isAuthenticated) { - await logtoClient.signIn(window.location.origin); + await logtoClient.signIn(exactRedirectUri); return; }