@@ -51,111 +51,54 @@ export async function localUrl({
51
51
localhost ?: boolean
52
52
https ?: boolean
53
53
} = { } ) : 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' )
58
55
59
56
switch ( type ) {
60
57
case 'frontend' :
61
58
if ( network ) return await createLocalTunnel ( config . ports ?. frontend || 3000 )
62
-
63
59
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
70
61
case 'backend' :
71
62
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
-
83
63
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
90
66
case 'admin' :
91
67
if ( network ) return await createLocalTunnel ( config . ports ?. admin || 3002 )
92
-
93
68
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
100
71
case 'library' :
101
72
if ( network ) return await createLocalTunnel ( config . ports ?. library || 3003 )
102
-
103
73
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
110
76
case 'email' :
111
77
if ( network ) return await createLocalTunnel ( config . ports ?. email || 3005 )
112
-
113
78
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
120
81
case 'desktop' :
121
82
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
130
86
case 'docs' :
131
- if ( network ) return await createLocalTunnel ( config . ports ?. desktop || 3006 )
132
-
87
+ if ( network ) return await createLocalTunnel ( config . ports ?. docs || 3006 )
133
88
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
140
91
case 'inspect' :
141
- if ( network ) return await createLocalTunnel ( config . ports ?. desktop || 3007 )
142
-
92
+ if ( network ) return await createLocalTunnel ( config . ports ?. inspect || 3007 )
143
93
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
150
96
default :
151
97
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
158
98
}
99
+
100
+ if ( https ) return `https://${ url } `
101
+ return `http://${ url } `
159
102
}
160
103
161
104
export function defineStacksConfig ( config : StacksConfig ) : StacksConfig {
0 commit comments