This package, `lws-range`, is a middleware plugin designed for the `local-web-server` (`lws`) ecosystem, specifically adding robust support for HTTP Range Requests. It effectively wraps the `koa-range` library to integrate this functionality seamlessly into `lws` servers. As of version 4.0.1, it provides compliant handling of partial content requests, enabling clients to request specific byte ranges of a resource, which is crucial for features like video streaming, large file downloads with resume capabilities, and efficient caching. The project appears to be actively maintained, indicated by recent version releases and continuous integration. Its primary differentiator is its deep integration with the `lws` server, providing a simple `--stack` activation for this common HTTP feature without needing to manually configure low-level range request parsing. It mandates Node.js version 12.17 or higher.
npm install lws-rangeVerified import paths — ran on the pinned version, not inferred.
Sets up an `lws` server programmatically with `lws-range` and `lws-static` middleware, demonstrating how to enable HTTP Range Request support for static files. Includes setup for a test file.
Review your `lws` configuration and `lws-range` usage. If you relied on `koa-range` specific options, they are no longer directly exposed through `lws-range` and you may need to find `lws`-specific alternatives or adjust expectations.
Ensure your `lws` package is updated to version 5.x or later. Run `npm install lws@latest` or `yarn add lws@latest` to upgrade your `local-web-server` dependency.
Adjust the `stack` array in your `lws` configuration (or `--stack` CLI argument) to ensure `lwsRange()` appears earlier than `lwsStatic()` or similar static file handlers.
Verify the `Range` header sent by the client. Ensure the requested start and end bytes are valid and within the actual file's length. This error can also occur if the resource does not exist.
Ensure you are calling `lwsRange()` (with parentheses) when adding it to the `lws` stack, e.g., `stack: [lwsRange(), ...]` for programmatic usage or ensure the CLI option is correctly formatted.
Verify that `lws-range` is included in your `lws` stack and that its position is correct (e.g., before `lws-static`). Check for other middleware that might modify or remove the `Accept-Ranges` header.