- import {Base64} from 'js-base64';
- import website from '@/config/index';
- import {getToken} from '../util/auth';
- export function getTokenHeader(text= false) {
- let headers = {};
- headers['Authorization'] = `Basic ${Base64.encode(`${website.clientId}:${website.clientSecret}`)}`;
- //让每个请求携带token
- const token = getToken()
- if (token) headers['Blade-Auth'] = 'bearer ' + token
- //headers中配置text请求
- if (text === true) {
- headers["Content-Type"] = "text/plain";
- }
- return headers;
- }
|