I would like to add a Bearer token to the requests automatically.
An optional function which can modify the headers would solve this issue.
Sample:
new window.EmbeddedSandbox({
target: '#sandbox',
initialEndpoint: window.location.href,
initialState: {
sharedHeaders: {
'X-SpecialHeader': 'WILL_BE_REPLACED_AUTOMATICALLY'
}
},
modifyHeaders: async (url, headers) => {
// Add Authorization header if not provided
if (!headers.Authorization) {
const accessToken = await window.getAccessToken();
headers.Authorization = 'Bearer ' + accessToken;
}
// Modify special header if shared header is not unchecked
if (headers['X-SpecialHeader'] === 'WILL_BE_REPLACED_AUTOMATICALLY') {
const special = await window.getTheValue();
headers['X-SpecialHeader'] = special;
}
return headers;
}
});
I already provided a PR for this. #307
I would like to add a Bearer token to the requests automatically.
An optional function which can modify the headers would solve this issue.
Sample:
I already provided a PR for this. #307