mirror of
				https://github.com/crater-invoice/crater.git
				synced 2025-10-29 12:41:10 -04:00 
			
		
		
		
	
		
			
				
	
	
		
			32 lines
		
	
	
		
			607 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			607 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| import axios from 'axios'
 | |
| import Ls from '@/scripts/services/ls.js'
 | |
| 
 | |
| window.Ls = Ls
 | |
| window.axios = axios
 | |
| axios.defaults.withCredentials = true
 | |
| 
 | |
| axios.defaults.headers.common = {
 | |
|   'X-Requested-With': 'XMLHttpRequest',
 | |
| }
 | |
| 
 | |
| /**
 | |
|  * Interceptors
 | |
|  */
 | |
| 
 | |
| axios.interceptors.request.use(function (config) {
 | |
|   // Pass selected company to header on all requests
 | |
|   const companyId = Ls.get('selectedCompany')
 | |
| 
 | |
|   const authToken = Ls.get('auth.token')
 | |
| 
 | |
|   if (authToken) {
 | |
|     config.headers.common.Authorization = authToken
 | |
|   }
 | |
| 
 | |
|   if (companyId) {
 | |
|     config.headers.common['company'] = companyId
 | |
|   }
 | |
| 
 | |
|   return config
 | |
| })
 |