fixed middleware
All checks were successful
Build frontend / build (push) Successful in 53s

This commit is contained in:
mouazkh
2026-08-07 00:55:23 +03:00
parent f7afef03d4
commit 989a7f580f

View File

@ -25,12 +25,15 @@ import { getCustomerByUserId, getOwnerByUserId, loginWithEmail, loginWithPhone }
const TOKEN_KEY = "auth_token";
const USER_KEY = "cached_user";
const isSecureContext = () =>
typeof window !== "undefined" && window.location?.protocol === "https:";
const AuthService = Object.freeze({
addToken(token) {
if (!token || typeof token !== "string") return;
Cookies.set(TOKEN_KEY, token, {
expires: 7,
secure: true,
secure: isSecureContext(),
sameSite: "lax",
path: "/",
});
@ -51,7 +54,7 @@ const AuthService = Object.freeze({
cacheUser(user) {
Cookies.set(USER_KEY, JSON.stringify(user), {
expires: 7,
secure: true,
secure: isSecureContext(),
sameSite: "lax",
path: "/",
});