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