@@ -208,15 +208,25 @@ func Server(dflags *codersdk.DeploymentFlags, newAPI func(context.Context, *code
208
208
)
209
209
defer closeTunnel ()
210
210
211
- // If the access URL is empty, we attempt to run a reverse-proxy tunnel
212
- // to make the initial setup really simple.
211
+ // If the access URL is empty, we attempt to run a reverse-proxy
212
+ // tunnel to make the initial setup really simple.
213
213
if dflags .AccessURL .Value == "" {
214
214
cmd .Printf ("Opening tunnel so workspaces can connect to your deployment. For production scenarios, specify an external access URL\n " )
215
215
tunnel , tunnelErr , err = devtunnel .New (ctxTunnel , logger .Named ("devtunnel" ))
216
216
if err != nil {
217
217
return xerrors .Errorf ("create tunnel: %w" , err )
218
218
}
219
219
dflags .AccessURL .Value = tunnel .URL
220
+
221
+ if dflags .WildcardAccessURL .Value == "" {
222
+ u , err := parseURL (ctx , tunnel .URL )
223
+ if err != nil {
224
+ return xerrors .Errorf ("parse tunnel url: %w" , err )
225
+ }
226
+
227
+ // Suffixed wildcard access URL.
228
+ dflags .WildcardAccessURL .Value = fmt .Sprintf ("*--%s" , u .Hostname ())
229
+ }
220
230
}
221
231
222
232
accessURLParsed , err := parseURL (ctx , dflags .AccessURL .Value )
@@ -752,7 +762,7 @@ func Server(dflags *codersdk.DeploymentFlags, newAPI func(context.Context, *code
752
762
753
763
// parseURL parses a string into a URL. It works around some technically correct
754
764
// but undesired behavior of url.Parse by prepending a scheme if one does not
755
- // exist so that the URL does not get parsed improprely .
765
+ // exist so that the URL does not get parsed improperly .
756
766
func parseURL (ctx context.Context , u string ) (* url.URL , error ) {
757
767
var (
758
768
hasScheme = strings .HasPrefix (u , "http:" ) || strings .HasPrefix (u , "https:" )
@@ -1108,7 +1118,9 @@ func serveHandler(ctx context.Context, logger slog.Logger, handler http.Handler,
1108
1118
}
1109
1119
}()
1110
1120
1111
- return func () { _ = srv .Close () }
1121
+ return func () {
1122
+ _ = srv .Close ()
1123
+ }
1112
1124
}
1113
1125
1114
1126
// embeddedPostgresURL returns the URL for the embedded PostgreSQL deployment.
0 commit comments