Parses the Authorization header to extract JWT tokens following the Bearer
token authentication scheme. Validates the header format and returns the
token portion, or null if the header is missing or malformed.
This utility function is used by authentication middleware to extract tokens
from HTTP requests for verification. It handles the standard "Bearer "
format and provides safe parsing with null returns for invalid formats.
Parameters
OptionalauthHeader: string
Authorization header value (optional)
Returns null|string
Extracted token string or null if header is invalid/missing
Extract Bearer token from Authorization header
Parses the Authorization header to extract JWT tokens following the Bearer token authentication scheme. Validates the header format and returns the token portion, or null if the header is missing or malformed.
This utility function is used by authentication middleware to extract tokens from HTTP requests for verification. It handles the standard "Bearer"
format and provides safe parsing with null returns for invalid formats.