I had a Vue.JS application and use axios as a HTTP client by just importing its instance into the components (like this):
import axios from 'axios'
import cookies from '~/components/cookies.js';
var api = axios.create({
baseURL: 'http://localhost.api/',
timeout: 10000,
headers: {
'Authorization': cookies.get('token',''),
'X-Refresh-Token': cookies.get('refreshtoken'),
'Content-Type': 'application/json'
}
})
export default api;
...
import api from '~components/api.js'
Cookies were obtained from document.cookie. But now I moved to Nuxt and document is not defined during server rendering. So, how can I get cookies from the server request? (or even dynamically change token in the process)