Skip to content

Commit

Permalink
feat: token in sessionStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
kirinse committed Dec 21, 2024
1 parent 21dc479 commit 138820e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/atoms/auth.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { atomWithStorage } from "jotai/utils"

export const authTokenAtom = atomWithStorage<string>("token", "")
export const authTokenAtom = atomWithStorage<string>("token", "", sessionStorage)
4 changes: 2 additions & 2 deletions src/lib/api-fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export const apiFetch = ofetch.create({
const header = new Headers(options.headers)

options.headers = header
const token = localStorage.getItem("token")
const token = sessionStorage.getItem("token")
if (token) {
options.headers.append("Authorization", `Bearer ${JSON.parse(token)}`)
options.headers.append("Authorization", `Bearer ${token}`)
}

if (options.method && options.method.toLowerCase() !== "get") {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/(external)/login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function UserAuthForm({ className, ...props }: UserAuthFormProps) {
const { t } = useTranslation(["auth", "common"])
const redirectUrl =
new URLSearchParams(window.location.search).get("redirectTo") ||
"/dashboard"
"/number"

const loginMutation = useUserLoginMutation()
const navigate = useNavigate()
Expand Down

0 comments on commit 138820e

Please sign in to comment.