2018-02-25 06:27:32 +01:00
|
|
|
const isLocalhost = !process.browser ||
|
|
|
|
location.hostname === 'localhost' ||
|
|
|
|
location.hostname === '127.0.0.1'
|
2018-01-19 06:52:58 +01:00
|
|
|
|
2018-02-09 07:29:29 +01:00
|
|
|
function targetIsLocalhost (instanceName) {
|
2018-02-25 06:27:32 +01:00
|
|
|
return instanceName.startsWith('localhost:') || instanceName.startsWith('127.0.0.1:')
|
2018-01-19 06:52:58 +01:00
|
|
|
}
|
|
|
|
|
2018-02-09 07:29:29 +01:00
|
|
|
export function basename (instanceName) {
|
2018-01-19 06:52:58 +01:00
|
|
|
if (isLocalhost && targetIsLocalhost(instanceName)) {
|
|
|
|
return `http://${instanceName}`
|
|
|
|
}
|
|
|
|
return `https://${instanceName}`
|
2018-02-09 07:29:29 +01:00
|
|
|
}
|
2018-02-24 23:49:28 +01:00
|
|
|
|
|
|
|
export function auth (accessToken) {
|
|
|
|
return {
|
|
|
|
'Authorization': `Bearer ${accessToken}`
|
|
|
|
}
|
|
|
|
}
|