Skip to main content

datasette-redirect-to-https

PyPI Changelog Tests License

Datasette plugin that redirects all non-https requests to https

Installation

Install this plugin in the same environment as Datasette.

$ datasette install datasette-redirect-to-https

Usage

Once installed, incoming GET requests to the http:// protocol will be 301 redirected to the https:// equivalent page.

HTTP verbs other than GET will get a 405 Method Not Allowed HTTP error.

Configuration

Some hosting providers handle HTTPS for you, passing requests back to your application server over HTTP.

For this plugin to work correctly, you need to detect that they the original incoming request came in over HTTP.

Hosting providers like this often set an additional HTTP header such as x-forwarded-proto: http to let you know the original protocol.

You can configure datasette-redirect-to-https to respect this header using the following plugin configuration in metadata.json:

{
  "plugins": {
    "datasette-redirect-to-https": {
      "if_headers": {
        "x-forwarded-proto": "http"
      }
    }
  }
}

The above example will redirect to https:// if the incoming request has a x-forwarded-proto: http request header.

If multiple if_headers are listed, the redirect will occur if any of them match.

Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:

cd datasette-redirect-to-https
python3 -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest

Metadata

Release files for datasette-redirect-to-https 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for datasette-redirect-to-https 0.2
File Size Uploaded
datasette-redirect-to-https-0.2.tar.gz 3.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for datasette-redirect-to-https 0.2
File Interpreter ABI Platform
datasette_redirect_to_https-0.2-py3-none-any.whl Python 3 none any Details

Total release size: 6.6 kB

Release files / datasette-redirect-to-https-0.2.tar.gz

Download URL datasette-redirect-to-https-0.2.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
522bbf1b159eacf065d64d2913f91ffe9dcd5adc66ee229dcb5c7dc1509822bc
BLAKE2b-256 checksum
How to use checksums
eb8973df25db5bffd367545399ad2a3dfd824f946ba480f277e8564c8536b554
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / datasette_redirect_to_https-0.2-py3-none-any.whl

Download URL datasette_redirect_to_https-0.2-py3-none-any.whl
Size 3.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
43834db734a1d3aead5fde413a6527ca54f074d4ecc4a837ce52994c75ee10e2
BLAKE2b-256 checksum
How to use checksums
294bec4511c9533350841bceaf3dbb4d72508c60cdd3bd806ed1893ec430d88b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release history Release notifications | RSS feed

This release

0.2 This release

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page