Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 17 additions & 18 deletions internal/cli/quickstarts.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,16 +464,14 @@ func setupQuickstartCmd(cli *cli) *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()

// Normalize the type to lowercase for comparison.
normalizedType := strings.ToLower(inputs.Type)

if inputs.Type != "" {
normalizedType := strings.ToLower(inputs.Type)
if normalizedType != "vite" && normalizedType != "nextjs" {
return fmt.Errorf("unsupported quickstart type: %s (supported types: vite, nextjs)", inputs.Type)
}
}

if err := qsType.Select(cmd, &inputs.Type, []string{"vite (React, Svelte, Vue, Vanilla JS)", "nextjs"}, nil); err != nil {
if err := qsType.Select(cmd, &inputs.Type, []string{"vite", "nextjs"}, nil); err != nil {
return err
}

Expand All @@ -489,31 +487,32 @@ func setupQuickstartCmd(cli *cli) *cobra.Command {

var appType, baseURL, envFileName string
var callbacks, logoutURLs, origins, webOrigins []string
var defaultPort string

switch {
case strings.HasPrefix(normalizedType, "vite"):
switch inputs.Type {
case "vite":
appType = appTypeSPA
if inputs.Port == 0 {
inputs.Port = 5173
}
defaultPort = "5173"
envFileName = ".env"

case strings.HasPrefix(normalizedType, "nextjs"):
case "nextjs":
appType = appTypeRegularWeb
if inputs.Port == 0 {
inputs.Port = 3000
}
defaultPort = "3000"
envFileName = ".env.local"
}

if err := qsPort.Ask(cmd, &inputs.Port, &defaultPort); err != nil {
return err
}

if inputs.Port < 1024 || inputs.Port > 65535 {
return fmt.Errorf("invalid port number: %d (must be between 1024 and 65535)", inputs.Port)
}

baseURL = fmt.Sprintf("http://localhost:%d", inputs.Port)

// Configure URLs based on app type.
if strings.HasPrefix(normalizedType, "vite") {
if inputs.Type == "vite" {
callbacks = []string{baseURL}
logoutURLs = []string{baseURL}
origins = []string{baseURL}
Expand Down Expand Up @@ -544,7 +543,7 @@ func setupQuickstartCmd(cli *cli) *cobra.Command {
ClientMetadata: &metadata,
}

if strings.HasPrefix(normalizedType, "vite") {
if inputs.Type == "vite" {
a.AllowedOrigins = &origins
a.WebOrigins = &webOrigins
}
Expand All @@ -564,12 +563,12 @@ func setupQuickstartCmd(cli *cli) *cobra.Command {

var envContent strings.Builder

switch {
case strings.HasPrefix(normalizedType, "vite"):
switch inputs.Type {
case "vite":
envContent.WriteString(fmt.Sprintf("VITE_AUTH0_DOMAIN=%s\n", tenant.Domain))
envContent.WriteString(fmt.Sprintf("VITE_AUTH0_CLIENT_ID=%s\n", a.GetClientID()))

case strings.HasPrefix(normalizedType, "nextjs"):
case "nextjs":
secret, err := generateState(32)
if err != nil {
return fmt.Errorf("failed to generate AUTH0_SECRET: %w", err)
Expand Down
Loading