-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Cookies from 'js-cookie'; | ||
|
||
export const ACCESS_TOKEN_KEY = 'accessToken'; | ||
|
||
interface CookieOptions { | ||
expires?: number | Date; | ||
path?: string; | ||
secure?: boolean; | ||
sameSite?: 'strict' | 'lax' | 'none'; | ||
} | ||
|
||
const defaultOptions: CookieOptions = { | ||
path: '/', | ||
secure: process.env.NODE_ENV === 'production', | ||
sameSite: 'strict', | ||
}; | ||
|
||
export const setCookie = (name: string, value: string, options?: CookieOptions) => { | ||
Cookies.set(name, value, { ...defaultOptions, ...options }); | ||
}; | ||
|
||
export const getCookie = (name: string) => { | ||
return Cookies.get(name); | ||
}; | ||
|
||
export const removeCookie = (name: string, options?: CookieOptions) => { | ||
Cookies.remove(name, { ...defaultOptions, ...options }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters