removed the dynamic dashboard path option as it could complicate unnecessary too many things (oauth2 redirects, default email templates, etc.)

This commit is contained in:
Gani Georgiev 2024-11-12 12:32:26 +02:00
parent 1ca90e5e8b
commit 10a5c685ab
2 changed files with 2 additions and 25 deletions

View File

@ -27,11 +27,6 @@ type ServeConfig struct {
// ShowStartBanner indicates whether to show or hide the server start console message. // ShowStartBanner indicates whether to show or hide the server start console message.
ShowStartBanner bool ShowStartBanner bool
// DashboardPath specifies the route path to the superusers dashboard (default to "_").
//
// Currently it is limited to a single path segment (this is because the UI is not extendable at the moment).
DashboardPath string
// HttpAddr is the TCP address to listen for the HTTP server (eg. "127.0.0.1:80"). // HttpAddr is the TCP address to listen for the HTTP server (eg. "127.0.0.1:80").
HttpAddr string HttpAddr string
@ -66,15 +61,6 @@ func Serve(app core.App, config ServeConfig) error {
config.AllowedOrigins = []string{"*"} config.AllowedOrigins = []string{"*"}
} }
if config.DashboardPath == "" {
config.DashboardPath = "_"
} else {
config.DashboardPath = strings.Trim(config.DashboardPath, "/")
if strings.Contains(config.DashboardPath, "/") {
return errors.New("the dashboard path must be single path segment: _, admin, etc.")
}
}
// ensure that the latest migrations are applied before starting the server // ensure that the latest migrations are applied before starting the server
err := app.RunAllMigrations() err := app.RunAllMigrations()
if err != nil { if err != nil {
@ -91,7 +77,7 @@ func Serve(app core.App, config ServeConfig) error {
AllowMethods: []string{http.MethodGet, http.MethodHead, http.MethodPut, http.MethodPatch, http.MethodPost, http.MethodDelete}, AllowMethods: []string{http.MethodGet, http.MethodHead, http.MethodPut, http.MethodPatch, http.MethodPost, http.MethodDelete},
})) }))
pbRouter.GET("/"+config.DashboardPath+"/{path...}", Static(ui.DistDirFS, false)). pbRouter.GET("/_/{path...}", Static(ui.DistDirFS, false)).
BindFunc(func(e *core.RequestEvent) error { BindFunc(func(e *core.RequestEvent) error {
// ingore root path // ingore root path
if e.Request.PathValue(StaticWildcardParam) != "" { if e.Request.PathValue(StaticWildcardParam) != "" {
@ -255,7 +241,7 @@ func Serve(app core.App, config ServeConfig) error {
} }
} }
baseURL := fmt.Sprintf("%s://%s", schema, addr) baseURL := fmt.Sprintf("%s://%s", schema, addr)
dashboardURL := fmt.Sprintf("%s/%s", baseURL, config.DashboardPath) dashboardURL := fmt.Sprintf("%s/_", baseURL)
if config.ShowStartBanner { if config.ShowStartBanner {
date := new(strings.Builder) date := new(strings.Builder)

View File

@ -15,7 +15,6 @@ func NewServeCommand(app core.App, showStartBanner bool) *cobra.Command {
var allowedOrigins []string var allowedOrigins []string
var httpAddr string var httpAddr string
var httpsAddr string var httpsAddr string
var dashboardPath string
command := &cobra.Command{ command := &cobra.Command{
Use: "serve [domain(s)]", Use: "serve [domain(s)]",
@ -40,7 +39,6 @@ func NewServeCommand(app core.App, showStartBanner bool) *cobra.Command {
err := apis.Serve(app, apis.ServeConfig{ err := apis.Serve(app, apis.ServeConfig{
HttpAddr: httpAddr, HttpAddr: httpAddr,
HttpsAddr: httpsAddr, HttpsAddr: httpsAddr,
DashboardPath: dashboardPath,
ShowStartBanner: showStartBanner, ShowStartBanner: showStartBanner,
AllowedOrigins: allowedOrigins, AllowedOrigins: allowedOrigins,
CertificateDomains: args, CertificateDomains: args,
@ -75,12 +73,5 @@ func NewServeCommand(app core.App, showStartBanner bool) *cobra.Command {
"TCP address to listen for the HTTPS server\n(if domain args are specified - default to 0.0.0.0:443, otherwise - default to empty string, aka. no TLS)\nThe incoming HTTP traffic also will be auto redirected to the HTTPS version", "TCP address to listen for the HTTPS server\n(if domain args are specified - default to 0.0.0.0:443, otherwise - default to empty string, aka. no TLS)\nThe incoming HTTP traffic also will be auto redirected to the HTTPS version",
) )
command.PersistentFlags().StringVar(
&dashboardPath,
"dashboard",
"_",
"The route path to the superusers dashboard (currently limited to a single path segment)",
)
return command return command
} }