// use case

Expose your FastAPI app on a public HTTPS URL

uvicorn binds to localhost. For webhooks, OAuth, or another service calling your API, you need a public URL with a real cert. lrok wraps uvicorn unchanged.
  1. Run uvicorn

    $ uvicorn main:app --reload --port 8000
  2. Tunnel

    $ lrok http 8000
  3. Forwarded headers

    Pass --proxy-headers to uvicorn so it trusts X-Forwarded-Proto/Host from lrok. Otherwise self-generated URLs in your responses come back as http://127.0.0.1.

    $ uvicorn main:app --proxy-headers --port 8000

// why lrok for this

FastAPI's automatic OpenAPI / Swagger UI uses the request URL to build links. Real https:// from lrok keeps the docs page consistent with how clients will actually call you.

Related workflows