Skip to content
Open
Show file tree
Hide file tree
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
20 changes: 14 additions & 6 deletions cmd/lk/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,20 @@ func createAgentClientWithOpts(ctx context.Context, cmd *cli.Command, opts ...lo
return ctx, err
}
if configExists {
projectSubdomainMatch := subdomainPattern.FindStringSubmatch(project.URL)
if len(projectSubdomainMatch) < 2 {
return ctx, fmt.Errorf("invalid project URL [%s]", project.URL)
}
if projectSubdomainMatch[1] != lkConfig.Project.Subdomain {
return ctx, fmt.Errorf("project does not match agent subdomain [%s]", lkConfig.Project.Subdomain)
// When agents_url is explicitly configured, skip subdomain validation.
// This supports self-hosted deployments where the project URL does not
// follow the <subdomain>.livekit.cloud pattern.
agentsURLOverride := lkConfig.Agent != nil && lkConfig.Agent.AgentsURL != ""
if !agentsURLOverride {
projectSubdomainMatch := subdomainPattern.FindStringSubmatch(project.URL)
if len(projectSubdomainMatch) < 2 {
return ctx, fmt.Errorf("invalid project URL [%s]", project.URL)
}
if projectSubdomainMatch[1] != lkConfig.Project.Subdomain {
return ctx, fmt.Errorf("project does not match agent subdomain [%s]", lkConfig.Project.Subdomain)
}
} else {
os.Setenv("LK_AGENTS_URL", lkConfig.Agent.AgentsURL)
}
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/config/livekit.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ type LiveKitTOMLProjectConfig struct {
}

type LiveKitTOMLAgentConfig struct {
ID string `toml:"id"`
ID string `toml:"id"`
AgentsURL string `toml:"agents_url,omitempty"`
}

func NewLiveKitTOML(forSubdomain string) *LiveKitTOML {
Expand Down
Loading