Skip to content

Commit

Permalink
add Github Token to request when running on github codespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
IvoLeist committed Dec 7, 2023
1 parent b1e4360 commit 2860815
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions convertPheno_client/src/code/axiosInstance.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import axios from 'axios';

const axiosInstance = axios.create({
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Connection': 'keep-alive',
}
})

axiosInstance.interceptors.request.use(config => {
if (window.location.hostname.endsWith('.github.dev') ) {
console.log('Running in Codespaces');
config.headers['X-Github-Token'] = import.meta.env.VITE_GITHUB_TOKEN;
}
console.log('config', config);
return config;
}, error => {
console.log('error', error);
return Promise.reject(error);
});

export default axiosInstance;

0 comments on commit 2860815

Please sign in to comment.