Skip to content

Commit 78f1614

Browse files
committed
fix: only add X-XSRF-TOKEN header to laravelSanctum strategy
1 parent 79c7b36 commit 78f1614

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/plugin.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,16 @@ function getHeaders ({ app }) {
1515
<% if (options.authModule) { %>
1616
if (app.$auth) {
1717
const strategy = app.$auth.strategy
18-
const tokenName = strategy.options.token.name || 'Authorization'
19-
const token = app.$auth.token.get()
2018

21-
if (token) {
22-
headers[tokenName] = token
19+
if (strategy.options.name === 'laravelSanctum') {
2320
headers['X-XSRF-TOKEN'] = app.$auth.$storage.getCookies()['XSRF-TOKEN']
21+
} else {
22+
const tokenName = strategy.options.token.name || 'Authorization'
23+
const token = app.$auth.token.get()
24+
25+
if (token) {
26+
headers[tokenName] = token
27+
}
2428
}
2529
}
2630
<% } %>

0 commit comments

Comments
 (0)