{"record":{"id":"e1ce6155eb52be90","repo":"nats-io/nats-server","slug":"unable-to-parse-allowed-origin-v","errorCode":null,"errorMessage":"unable to parse allowed origin: %v","messagePattern":"unable to parse allowed origin: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/websocket.go","lineNumber":1140,"sourceCode":"// Validate the websocket related options.\nfunc validateWebsocketOptions(o *Options) error {\n\two := &o.Websocket\n\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}","sourceCodeStart":1122,"sourceCodeEnd":1158,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/websocket.go#L1122-L1158","documentation":"Returned by validateWebsocketOptions() when an entry in the websocket allowed_origins option cannot be parsed by url.ParseRequestURI(). Startup aborts because an origin that cannot be parsed can never match, indicating a configuration typo or malformed value.","triggerScenarios":"Thrown at server/websocket.go:1140 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the malformed allowed_origins entry in the server configuration","Use absolute URLs like https://example.com instead of hostnames or wildcards","Quote values containing special characters in the config file"],"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-08T10:18:20.063Z"}