Support the ongoing development of Laravel.io →
Vue.js API Laravel

I'm trying to authenticate my api route with sanctum while using vue.js but I'm getting a headers error

bootstarp.js

axios.interceptors.request.use(function (config) { config.headers.common = { 'Authorization': Bearer ${localStorage.getItem('token')}, 'Content-Type': 'application/json', 'Accept': 'application/json' } return config })

Getting this error:

DOMException: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': 'Bearer 100|paUaKhln1hiQUGWUyRshAC5fL8qS9qMhsR5n6CHd' is not a valid HTTP header field value.

Last updated 3 years ago.
0

Hey,

Sanctum tokens/cookie values are base64 encoded. The value you are passing as header is nothing that's Sanctum compatible. Where did you get that value from?

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Hamza Ikram hamza094 Joined 31 Aug 2019

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.