login fix v2
This commit is contained in:
@@ -28,6 +28,17 @@ import { fetchManagedAccounts } from "./services/accountsService";
|
||||
import { useScan } from "./context/ScanContext";
|
||||
import ScanningLoader from "./components/ui/ScanningLoader";
|
||||
|
||||
/** Prüft, ob der Fehler wie ein CORS- oder Netzwerkfehler aussieht (Request wird vom Browser blockiert). */
|
||||
function isCorsOrNetworkError(e) {
|
||||
const msg = (e?.message || "").toLowerCase();
|
||||
return (
|
||||
msg.includes("failed to fetch") ||
|
||||
msg.includes("network error") ||
|
||||
msg.includes("networkrequestfailed") ||
|
||||
(e?.name && e.name.toLowerCase().includes("network"))
|
||||
);
|
||||
}
|
||||
|
||||
export default function App() {
|
||||
const { route, navigate } = useHashRoute();
|
||||
const { scanning, scanProgress } = useScan();
|
||||
@@ -125,7 +136,10 @@ export default function App() {
|
||||
|
||||
await handoffJwtToExtension();
|
||||
} catch (e) {
|
||||
setStatus({ loading: false, authed: false, error: "" });
|
||||
const errorMsg = isCorsOrNetworkError(e)
|
||||
? "Verbindung zum Auth-Server fehlgeschlagen. Bitte in Appwrite die aktuelle App-URL (z. B. https://www.eship.pro) unter Platforms eintragen (CORS)."
|
||||
: "";
|
||||
setStatus({ loading: false, authed: false, error: errorMsg });
|
||||
setAuthUser(null);
|
||||
setHasUserDoc(false);
|
||||
setUserExtensionLoad(null);
|
||||
@@ -177,7 +191,10 @@ export default function App() {
|
||||
|
||||
await handoffJwtToExtension();
|
||||
} catch (e) {
|
||||
setStatus({ loading: false, authed: false, error: "Login fehlgeschlagen" });
|
||||
const errorMsg = isCorsOrNetworkError(e)
|
||||
? "Verbindung blockiert (CORS). In Appwrite unter Auth → Platforms die App-URL (z. B. https://www.eship.pro) hinzufügen."
|
||||
: "Login fehlgeschlagen";
|
||||
setStatus({ loading: false, authed: false, error: errorMsg });
|
||||
setAuthUser(null);
|
||||
setHasUserDoc(false);
|
||||
setUserExtensionLoad(null);
|
||||
|
||||
Reference in New Issue
Block a user