Skip to content

Commit 31a1098

Browse files
feat: miragte from auth module v4 to v5 (#14)
* feat: migrate to auth module v5 * fix: add referer header Co-authored-by: radudiaconu0 <radu0071@gmail.com> * fix: add X-XSRF-TOKEN header to `laravelSanctum` strategy Co-authored-by: radudiaconu0 <radu0071@gmail.com> * fix(auth): fix token instance * fix: move referer header to Laravel Sanctum conditional Co-authored-by: radudiaconu0 <radu0071@gmail.com>
1 parent 8138e1f commit 31a1098

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/plugin.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@ function getHeaders ({ app }) {
1212
<% if (options.authModule) { %>
1313
if (app.$auth) {
1414
const strategy = app.$auth.strategy
15-
const tokenName = strategy.options.tokenName || 'Authorization'
16-
const token = app.$auth.getToken(strategy.name)
1715

18-
if (token) {
19-
headers[tokenName] = token
16+
if (strategy.options.name === 'laravelSanctum') {
17+
headers.referer = location.origin
18+
headers['X-XSRF-TOKEN'] = app.$auth.$storage.getCookies()['XSRF-TOKEN']
19+
} else {
20+
const tokenName = strategy.options.token.name || 'Authorization'
21+
const token = app.$auth.strategy.token.get()
22+
23+
if (token) {
24+
headers[tokenName] = token
25+
}
2026
}
2127
}
2228
<% } %>

0 commit comments

Comments
 (0)