We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8b1b5ec commit 93a1cf6Copy full SHA for 93a1cf6
src/utils.ts
@@ -163,13 +163,18 @@ export const initAuth = function initAuth(options) {
163
'You must pass the `commit` function in the `initAuth` function options.'
164
)
165
}
166
- if (!req) {
+ let cookies
167
+ if (req) {
168
+ cookies = req.headers.cookie
169
+ } else if (document && document.cookie) {
170
+ cookies = document.cookie
171
+ } else {
172
throw new Error(
173
'You must pass the `req` object in the `initAuth` function options.'
174
175
176
- const accessToken = readCookie(req.headers.cookie, cookieName)
177
+ const accessToken = readCookie(cookies, cookieName)
178
const payload = getValidPayloadFromToken(accessToken)
179
180
if (payload) {
0 commit comments