From abdde780ca1c1fc00891fcd9c5fd96b5fcd139e1 Mon Sep 17 00:00:00 2001 From: Drew Miley Date: Fri, 6 Nov 2020 15:58:07 +0000 Subject: [PATCH] Adds cors exception for localhost --- consumer/main.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/consumer/main.py b/consumer/main.py index e4353fb..6e4fe2e 100644 --- a/consumer/main.py +++ b/consumer/main.py @@ -4,11 +4,21 @@ from .utils.errors import CustomException, custom_error_handler, http_error_handler from fastapi import FastAPI +from fastapi.middleware.cors import CORSMiddleware from starlette.exceptions import HTTPException as StarletteHTTPException consumer = FastAPI(default_response_class=CustomResponse) +origins = ["*", "http://localhost:3000/"] +consumer.add_middleware( + CORSMiddleware, + allow_origins=origins, + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) + consumer.include_router(auth.router) consumer.include_router(devices.router)