Set referer header for cloud shell (#866)

This commit is contained in:
Alex Weininger 2023-10-05 13:19:21 -04:00 коммит произвёл GitHub
Родитель 1eeb2a484c
Коммит d62d0f60f1
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -805,6 +805,7 @@ export async function connectTerminal(accessTokens: AccessTokens, consoleUri: st
} }
async function initializeTerminal(accessTokens: AccessTokens, consoleUri: string, shellType: string, initialSize: Size) { async function initializeTerminal(accessTokens: AccessTokens, consoleUri: string, shellType: string, initialSize: Size) {
const consoleUrl = new URL(consoleUri);
return requestWithLogging({ return requestWithLogging({
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
uri: consoleUri + '/terminals?cols=' + initialSize.cols + '&rows=' + initialSize.rows + '&shell=' + shellType, uri: consoleUri + '/terminals?cols=' + initialSize.cols + '&rows=' + initialSize.rows + '&shell=' + shellType,
@ -812,7 +813,8 @@ async function initializeTerminal(accessTokens: AccessTokens, consoleUri: string
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Accept': 'application/json', 'Accept': 'application/json',
'Authorization': `Bearer ${accessTokens.resource}` 'Authorization': `Bearer ${accessTokens.resource}`,
'Referer': consoleUrl.protocol + "//" + consoleUrl.hostname + '/$hc' + consoleUrl.pathname + '/terminals',
}, },
simple: false, simple: false,
resolveWithFullResponse: true, resolveWithFullResponse: true,