Skip to content

Problem with WebSockets in development mode #1

@LoveBootCaptain

Description

@LoveBootCaptain

Hi @CoreyMSchafer ...

every time i want to start with fastAPI I'm struggling with this issue ...
Do you have any clue how to fix this?

INFO:     127.0.0.1:59250 - "WebSocket /" 403
INFO:     connection rejected (403 Forbidden)
INFO:     connection closed
INFO:     127.0.0.1:59257 - "WebSocket /" 403
INFO:     connection rejected (403 Forbidden)
INFO:     connection closed

I also tried the example from the fastAPI documentation with the same result. :(

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

app = FastAPI()

origins = [
    "*"
]

app.add_middleware(
    CORSMiddleware,
    allow_origins=origins,
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)


@app.get("/")
async def main():
    return {"message": "Hello World"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions