Alive Status Codes
ThealiveStatusCodes option specifies which HTTP status codes should be considered as valid (“alive”) links.
Configuration
Behavior
- Links returning any of these status codes are considered valid
- By default, Linkspector considers standard success codes as valid
- You can customize this list based on your specific requirements
Common Status Codes
| Status Code | Meaning | Typical Use |
|---|---|---|
| 200 | OK | Standard successful response |
| 201 | Created | Resource successfully created |
| 202 | Accepted | Request accepted for processing |
| 204 | No Content | Successful request with no content |
| 206 | Partial Content | Partial resource returned |
Example: Including Redirect Codes
Example: API-Specific Codes
If
aliveStatusCodes is not specified, Linkspector uses its default set of valid status codes.HTTP Headers
ThehttpHeaders option allows you to specify custom HTTP headers for requests to specific URLs, which is useful for accessing authenticated or protected resources.
Configuration
Behavior
- Each entry specifies a list of URLs and their corresponding headers
- Multiple URLs can share the same set of headers
- Headers are sent with every request to matching URLs
- Supports environment variable interpolation using
${VARIABLE_NAME}syntax
Using Environment Variables
For sensitive values like API keys or authentication tokens, use environment variables:1. Create a .env file
2. Reference variables in configuration
Common Use Cases
Basic Authentication
The value
Zm9vOmJhcg== is the Base64 encoding of username:password.Bearer Token Authentication
API Key Authentication
Custom User Agent
Multiple URLs with Same Headers
Multiple Header Sets
You can define different headers for different URLs:Follow Redirects
ThefollowRedirects option controls how Linkspector handles HTTP redirects (status codes like 301, 302, 307, 308).
Configuration
Behavior
When followRedirects: true (default)
- Linkspector follows HTTP redirects to their final destination
- The status of the link is determined by the final destination’s status code
- If the final destination returns 200 OK, the original link is reported as “alive”
- A message indicates that the link was redirected
- Original link:
http://example.com/old - Redirects to:
http://example.com/new(200 OK) - Result: Link is reported as “alive” (200) with a redirect message
When followRedirects: false
- Linkspector does NOT follow HTTP redirects
- If a link returns a redirect status code, it’s reported as an error
- The reported status code is the original redirect code (301, 302, etc.)
- The error message indicates that the link redirected but following was disabled
- Original link:
http://example.com/old - Returns: 301 Moved Permanently
- Result: Link is reported as “error” with status code 301
When to Use followRedirects: false
Consider disabling redirect following when:
- You want to catch redirects: To identify and update old URLs in your documentation
- Performance concerns: Following redirects adds latency to link checking
- Redirect chains: To avoid potential infinite redirect loops
- Documentation hygiene: To ensure all links point directly to their final destination
Example: Strict Link Checking
Example: Permissive Checking
The default value is
true, which is suitable for most use cases where you want to verify that links eventually resolve to valid content.Complete Example
Here’s a comprehensive example combining all HTTP options:.env file:
- Considers status codes 200, 201, 202, and 204 as valid
- Sends appropriate authentication headers to different APIs
- Uses environment variables for sensitive credentials
- Follows redirects to verify final destinations
- Checks all files in the
./docsdirectory