fix: location url for services and apps

This commit is contained in:
Andras Bacsai
2022-07-18 07:45:29 +00:00
parent 017ba61dc9
commit 60a53bb812
5 changed files with 34 additions and 28 deletions

View File

@@ -44,7 +44,7 @@ export const status: Writable<any> = writable({
initialLoading: true,
loading: false,
isRunning: false
},
},
database: {
initialLoading: true,
loading: false,
@@ -57,3 +57,17 @@ export const features = readable({
beta: window.localStorage.getItem('beta') === 'true',
latestVersion: window.localStorage.getItem('latestVersion')
});
export const location: Writable<null | string> = writable(null)
export const setLocation = (resource: any) => {
console.log(GITPOD_WORKSPACE_URL)
if (GITPOD_WORKSPACE_URL && resource.exposePort) {
const { href } = new URL(GITPOD_WORKSPACE_URL);
const newURL = href
.replace('https://', `https://${resource.exposePort}-`)
.replace(/\/$/, '');
location.set(newURL)
} else {
location.set(resource.fqdn)
}
}