gofiber/fiber · error
fiber: keyauth error_uri must be absolute
Error message
fiber: keyauth error_uri must be absolute
What it means
When keyauth Config.ErrorURI is provided, the library parses it with url.Parse and requires an absolute URL (one with a scheme and host, e.g. https://...). A relative path or a value that fails to parse panics in configDefault(), because RFC 6750 requires error_uri to be an absolute URI.
Source
Thrown at middleware/keyauth/config.go:147
cfg.Challenge = fmt.Sprintf("ApiKey realm=%q", cfg.Realm)
}
if cfg.Error != "" {
switch cfg.Error {
case ErrorInvalidRequest, ErrorInvalidToken, ErrorInsufficientScope:
default:
panic("fiber: keyauth unsupported error token")
}
}
if cfg.ErrorDescription != "" && cfg.Error == "" {
panic("fiber: keyauth error_description requires error")
}
if cfg.ErrorURI != "" {
if cfg.Error == "" {
panic("fiber: keyauth error_uri requires error")
}
if u, err := url.Parse(cfg.ErrorURI); err != nil || !u.IsAbs() {
panic("fiber: keyauth error_uri must be absolute")
}
}
if cfg.Error == ErrorInsufficientScope {
if cfg.Scope == "" {
panic("fiber: keyauth insufficient_scope requires scope")
}
for scope := range strings.SplitSeq(cfg.Scope, " ") {
if scope == "" || !isScopeToken(scope) {
panic("fiber: keyauth scope contains invalid token")
}
}
} else if cfg.Scope != "" {
panic("fiber: keyauth scope requires insufficient_scope error")
}
return cfg
}
View on GitHub (pinned to 9a4c7e57fe)
Solutions
- Provide a full absolute URL including scheme, e.g. "https://example.com/docs/auth-errors".
- Build the URL from a configured base so it stays absolute across environments.
- Verify the value parses with net/url and u.IsAbs() returns true before passing it to keyauth.New().
Example fix
// before
app.Use(keyauth.New(keyauth.Config{
Validator: validateKey,
Error: keyauth.ErrorInvalidToken,
ErrorURI: "/docs/auth-errors",
}))
// after
app.Use(keyauth.New(keyauth.Config{
Validator: validateKey,
Error: keyauth.ErrorInvalidToken,
ErrorURI: "https://example.com/docs/auth-errors",
})) Defensive patterns
Strategy: validation
Validate before calling
if cfg.ErrorURI != "" {
u, err := url.Parse(cfg.ErrorURI)
if err != nil || !u.IsAbs() {
log.Fatalf("keyauth: ErrorURI %q must be an absolute URL", cfg.ErrorURI)
}
} Prevention
- Store fully-qualified base URLs in config and concatenate paths onto them.
- Run url.Parse + IsAbs() in a config-validation step before constructing middleware.
When it happens
Trigger: Setting Config.ErrorURI to a relative path like "/docs/errors", a path without scheme like "example.com/errors", or a malformed string that url.Parse rejects. This triggers the panic at middleware construction.
Common situations: Developer reuses an internal route path instead of a fully-qualified URL. Environment-specific base URLs omitted because the dev assumed a relative path is fine. Copying a path from a frontend router config.
Related errors
- fiber: keyauth unsupported error token
- fiber: keyauth error_description requires error
- fiber: keyauth error_uri requires error
- fiber: keyauth insufficient_scope requires scope
- fiber: keyauth scope contains invalid token
AI-assisted analysis of gofiber/fiber@9a4c7e57fe (2026-08-04).
Data as JSON: /data/errors/3dd0367705034193.json.
Report an issue: GitHub.