mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-04-14 14:36:34 +00:00
Fix CORS issue with X-Balena-Client header
Change-type: patch See: https://balena.fibery.io/Work/Project/Extend-the-X-Balena-Client-header-to-include-the-UI-CLI-version-as-well-1174
This commit is contained in:
parent
666ce876e6
commit
64d1943804
@ -46,9 +46,13 @@ export const onceAsync = <T>(fn: () => Promise<T>) => {
|
||||
|
||||
const cliXBalenaClientHeaderInterceptor: BalenaSdk.Interceptor = {
|
||||
request($request) {
|
||||
// We intentionally overwrite the sdk version string from the header
|
||||
// to conserve bandwidth.
|
||||
$request.headers['X-Balena-Client'] = `balena-cli/${version}`;
|
||||
if ($request.headers['X-Balena-Client']) {
|
||||
// We intentionally overwrite the sdk version string from the header
|
||||
// to conserve bandwidth. We only do that when the SDK already has specified
|
||||
// the X-Balena-Client header, since that signals that this is a safe url to
|
||||
// include the extra header and will not cause CORS errors.
|
||||
$request.headers['X-Balena-Client'] = `balena-cli/${version}`;
|
||||
}
|
||||
return $request;
|
||||
},
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user