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

How to enable CORS? #171

Open
perogeremmer opened this issue Apr 15, 2024 · 1 comment
Open

How to enable CORS? #171

perogeremmer opened this issue Apr 15, 2024 · 1 comment

Comments

@perogeremmer
Copy link

Hi, May I know how to enable CORS in Socketify?

I am trying to add any CORS using middleware but it seems doesn't work at all.

async def cors_middleware(req, res):
    res.set_header("Access-Control-Allow-Origin", "*")
    res.set_header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS")
    res.set_header("Access-Control-Allow-Headers", "Content-Type")

auth_router = MiddlewareRouter(app, cors_middleware)
@leunga1000
Copy link
Contributor

I think returning False/None (this function returns None implicitly) stops execution, so you may wish to return True at the bottom

https://docs.socketify.dev/middlewares.html

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

2 participants