vue-resource interceptor for auth headers

后端 未结 2 1027
独厮守ぢ
独厮守ぢ 2020-12-31 09:26

I am trying to set up a Vuejs fronted application (vue-cli webpack template) to sit on top of my Laravel API.

I am able to get a successful response from the API wit

2条回答
  •  一生所求
    2020-12-31 09:49

    Add this option:

    Vue.http.options.credentials = true;
    

    And use the interceptors for global way:

    Vue.http.interceptors.push(function(request, next) {
    
    request.headers['Authorization'] = 'Basic abc' //Base64
    request.headers['Accept'] = 'application/json'
    next()
    

    });

提交回复
热议问题