myheats

Live heats, scoring and leaderboard for sport events
git clone https://git.in0rdr.ch/myheats.git
Log | Files | Refs | Pull requests | README | LICENSE

commit 706f8e12e6a2aa18f352ddba36762a433c9ee99a
parent 2f834c13589ae03bf4b1e3acfcaed042d4489d73
Author: Andreas Gruhler <andreas.gruhler@adfinis.com>
Date:   Wed, 18 Sep 2024 22:42:59 +0200

fix(magic): use navigate instead of redirect

Diffstat:
Msrc/AuthVerify.jsx | 9++++++---
Asrc/Settings.jsx | 0
2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/AuthVerify.jsx b/src/AuthVerify.jsx @@ -1,6 +1,6 @@ import { useState, useEffect } from 'react' import { CookiesProvider, useCookies } from 'react-cookie' -import { redirect } from "react-router-dom" +import { useNavigate } from "react-router-dom" const api_uri = import.meta.env.VITE_API_URI const api_port = import.meta.env.VITE_API_PORT @@ -11,6 +11,7 @@ function AuthVerify() { const [session, setSession, removeSession] = useCookies(['auth']) const queryParameters = new URLSearchParams(window.location.search) const token = queryParameters.get("token") + const navigate = useNavigate() useEffect(() => { (async () => { @@ -24,13 +25,15 @@ function AuthVerify() { // Set client session (https://www.npmjs.com/package/react-cookie) setSession('auth', data, { path: '/', + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value sameSite: 'strict', secure: process.env.NODE_ENV !== 'development', maxAge: parseInt(session_ttl), }) - // redirect if everything ok - return redirect("/"); + // Redirect if everything ok. Use navigate in an effect: + // https://reactrouter.com/en/main/hooks/use-navigate + return navigate("/"); } })(); }, []); diff --git a/src/Settings.jsx b/src/Settings.jsx