@@ -43,6 +43,7 @@ type virtualWorkspaces struct {
4343 kedgeClient * kedgeclient.Client // kedge client for fetching Edge resources
4444 staticTokens map [string ]struct {} // static tokens that bypass JWT SA requirement
4545 hubExternalURL string // external URL of the hub (used for kubeconfig generation)
46+ hubInternalURL string // internal URL of the hub (used for MCP→edges-proxy calls to avoid CDN loops)
4647 // authorizeFn performs delegated authentication and authorization against kcp.
4748 // Defaults to the package-level authorize function; injectable for testing.
4849 authorizeFn authorizeFnType
@@ -57,7 +58,9 @@ type VirtualWorkspaceHandlers struct {
5758// NewVirtualWorkspaces creates a new VirtualWorkspaceHandlers.
5859// kcpConfig is required for SA token authorization against kcp and for fetching Edge resources/secrets.
5960// hubExternalURL is the externally reachable URL of the hub, used when building kubeconfigs for agents.
60- func NewVirtualWorkspaces (cm * connman.ConnectionManager , kcpConfig * rest.Config , staticTokens []string , hubExternalURL string , logger klog.Logger ) (* VirtualWorkspaceHandlers , error ) {
61+ // hubInternalURL is the internal URL for MCP→edges-proxy calls to avoid CDN/proxy loops.
62+ // If empty, hubExternalURL is used as fallback.
63+ func NewVirtualWorkspaces (cm * connman.ConnectionManager , kcpConfig * rest.Config , staticTokens []string , hubExternalURL , hubInternalURL string , logger klog.Logger ) (* VirtualWorkspaceHandlers , error ) {
6164 staticTokenSet := make (map [string ]struct {}, len (staticTokens ))
6265 for _ , t := range staticTokens {
6366 staticTokenSet [t ] = struct {}{}
@@ -89,6 +92,7 @@ func NewVirtualWorkspaces(cm *connman.ConnectionManager, kcpConfig *rest.Config,
8992 kedgeClient : kedgeClient ,
9093 staticTokens : staticTokenSet ,
9194 hubExternalURL : hubExternalURL ,
95+ hubInternalURL : hubInternalURL ,
9296 authorizeFn : authorize ,
9397 logger : logger .WithName ("virtual-workspaces" ),
9498 },
0 commit comments