Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server header is not overridden #22

Open
lsmith77 opened this issue Jun 28, 2023 · 3 comments
Open

Server header is not overridden #22

lsmith77 opened this issue Jun 28, 2023 · 3 comments

Comments

@lsmith77
Copy link

I am using the following in a FastAPI project

server = secure.Server().set("Secure")

But the result is:

server: uvicorn
server: Secure

ie. it does not override the server header but simply adds another one.

@nashyeung
Copy link

I just got the same problem. Turns out it is uvicorn that injects the server header unconditionally.
You can run uvicorn with the --no-server-header option to disable this header.
Ref: https://www.uvicorn.org/settings/#http

@lsmith77
Copy link
Author

lsmith77 commented Sep 6, 2023

In my case I fixed it now using

    uvicorn.run(
        app,
        host="0.0.0.0",
        port=8000,
        server_header=False,
    )

@cak
Copy link
Owner

cak commented Apr 29, 2024

Thanks @lsmith77 and @nashyeung! I'll add this to the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants