Skip to content

Commit 066e48e

Browse files
committed
chore: wip
1 parent a25076d commit 066e48e

File tree

1 file changed

+22
-79
lines changed

1 file changed

+22
-79
lines changed

storage/framework/core/config/src/helpers.ts

Lines changed: 22 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -51,111 +51,54 @@ export async function localUrl({
5151
localhost?: boolean
5252
https?: boolean
5353
} = {}): Promise<string> {
54-
// Ensure url starts with http:// or https://
55-
// if (!url.startsWith('http://') && !url.startsWith('https://'))
56-
// url = 'https://' + url
57-
let url
54+
let url = domain.replace(/\.[^\.]+$/, '.localhost')
5855

5956
switch (type) {
6057
case 'frontend':
6158
if (network) return await createLocalTunnel(config.ports?.frontend || 3000)
62-
6359
if (localhost) return `http://localhost:${config.ports?.frontend}`
64-
65-
url = domain.replace(/\.[^\.]+$/, '.localhost')
66-
67-
if (https) return `https://${url}`
68-
69-
return url
60+
break
7061
case 'backend':
7162
if (network) return await createLocalTunnel(config.ports?.backend || 3001)
72-
73-
if (localhost) return `http://localhost:${config.ports?.backend}`
74-
75-
url = domain.replace(/\.[^\.]+$/, '.localhost/api/')
76-
77-
if (https) return `https://${url}`
78-
79-
return url
80-
case 'api':
81-
if (network) return await createLocalTunnel(config.ports?.backend || 3001)
82-
8363
if (localhost) return `http://localhost:${config.ports?.backend}`
84-
85-
url = domain.replace(/\.[^\.]+$/, '.localhost/api/')
86-
87-
if (https) return `https://${url}`
88-
89-
return url
64+
url = `api.${url}`
65+
break
9066
case 'admin':
9167
if (network) return await createLocalTunnel(config.ports?.admin || 3002)
92-
9368
if (localhost) return `http://localhost:${config.ports?.admin}`
94-
95-
url = domain.replace(/\.[^\.]+$/, '.localhost/admin/')
96-
97-
if (https) return `https://${url}`
98-
99-
return url
69+
url = `admin.${url}`
70+
break
10071
case 'library':
10172
if (network) return await createLocalTunnel(config.ports?.library || 3003)
102-
10373
if (localhost) return `http://localhost:${config.ports?.library}`
104-
105-
url = domain.replace(/\.[^\.]+$/, '.localhost/libs/')
106-
107-
if (https) return `https://${url}`
108-
109-
return url
74+
url = `libs.${url}`
75+
break
11076
case 'email':
11177
if (network) return await createLocalTunnel(config.ports?.email || 3005)
112-
11378
if (localhost) return `http://localhost:${config.ports?.email}`
114-
115-
url = domain.replace(/\.[^\.]+$/, '.localhost/email/')
116-
117-
if (https) return `https://${url}`
118-
119-
return url
79+
url = `email.${url}`
80+
break
12081
case 'desktop':
12182
if (network) return await createLocalTunnel(config.ports?.desktop || 3004)
122-
123-
if (localhost) return `http://localhost:${config.ports?.email}`
124-
125-
url = domain.replace(/\.[^\.]+$/, '.localhost/email/')
126-
127-
if (https) return `https://${url}`
128-
129-
return url
83+
if (localhost) return `http://localhost:${config.ports?.desktop}`
84+
url = `desktop.${url}`
85+
break
13086
case 'docs':
131-
if (network) return await createLocalTunnel(config.ports?.desktop || 3006)
132-
87+
if (network) return await createLocalTunnel(config.ports?.docs || 3006)
13388
if (localhost) return `http://localhost:${config.ports?.docs}`
134-
135-
url = domain.replace(/\.[^\.]+$/, '.localhost/docs/')
136-
137-
if (https) return `https://${url}`
138-
139-
return url
89+
url = `docs.${url}`
90+
break
14091
case 'inspect':
141-
if (network) return await createLocalTunnel(config.ports?.desktop || 3007)
142-
92+
if (network) return await createLocalTunnel(config.ports?.inspect || 3007)
14393
if (localhost) return `http://localhost:${config.ports?.inspect}`
144-
145-
url = domain.replace(/\.[^\.]+$/, '.localhost/__inspect/')
146-
147-
if (https) return `https://${url}`
148-
149-
return url
94+
url = `inspect.${url}`
95+
break
15096
default:
15197
if (localhost) return `http://localhost:${config.ports?.frontend}`
152-
153-
url = domain.replace(/\.[^\.]+$/, '.localhost')
154-
155-
if (https) return `https://${url}`
156-
157-
return url
15898
}
99+
100+
if (https) return `https://${url}`
101+
return `http://${url}`
159102
}
160103

161104
export function defineStacksConfig(config: StacksConfig): StacksConfig {

0 commit comments

Comments
 (0)