{"record":{"id":"3ac3c94f787e4ec9","repo":"nats-io/nats-server","slug":"unable-to-parse-allowed-origin-q-allowed-origins","errorCode":null,"errorMessage":"unable to parse allowed origin %q: allowed origins must be absolute URLs with http or https scheme","messagePattern":"unable to parse allowed origin %q: allowed origins must be absolute URLs with http or https scheme","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/websocket.go","lineNumber":1143,"sourceCode":"\t// If no port is defined, we don't care about other options\n\tif wo.Port == 0 {\n\t\treturn nil\n\t}\n\tif !wsAllowedFIPS() {\n\t\treturn fmt.Errorf(\"websocket: cannot be used in FIPS-140 mode when built with this Go version, use Go 1.26 or later\")\n\t}\n\t// Enforce TLS... unless NoTLS is set to true.\n\tif wo.TLSConfig == nil && !wo.NoTLS {\n\t\treturn errors.New(\"websocket requires TLS configuration\")\n\t}\n\t// Make sure that allowed origins, if specified, can be parsed.\n\tfor _, ao := range wo.AllowedOrigins {\n\t\tu, err := url.ParseRequestURI(ao)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to parse allowed origin: %v\", err)\n\t\t}\n\t\tif u.Scheme != \"http\" && u.Scheme != \"https\" {\n\t\t\treturn fmt.Errorf(\"unable to parse allowed origin %q: allowed origins must be absolute URLs with http or https scheme\", ao)\n\t\t}\n\t\tif u.Host == _EMPTY_ {\n\t\t\treturn fmt.Errorf(\"unable to parse allowed origin %q: host is required\", ao)\n\t\t}\n\t\tif _, _, err := wsGetHostAndPort(u.Scheme == \"https\", u.Host); err != nil {\n\t\t\treturn fmt.Errorf(\"unable to parse allowed origin: %v\", err)\n\t\t}\n\t}\n\t// If there is a NoAuthUser, we need to have Users defined and\n\t// the user to be present.\n\tif wo.NoAuthUser != _EMPTY_ {\n\t\tif err := validateNoAuthUser(o, wo.NoAuthUser); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\t// Token/Username not possible if there are users/nkeys\n\tif len(o.Users) > 0 || len(o.Nkeys) > 0 {\n\t\tif wo.Username != _EMPTY_ {","sourceCodeStart":1125,"sourceCodeEnd":1161,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/websocket.go#L1125-L1161","documentation":"Returned by validateWebsocketOptions() when an allowed_origins entry parses as a URI but its scheme is not http or https (or it lacks an absolute form with a host). Startup is rejected since origin comparison in websocket cross-origin checks requires absolute http(s) URLs; the offending value is named by %q.","triggerScenarios":"Thrown at server/websocket.go:1143 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rewrite the origin as an absolute URL, e.g. https://example.com","Remove scheme-relative or bare-host entries like example.com or //example.com","Only http and https schemes are accepted; drop ws:// or custom schemes"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}