zyriean commited on
Commit
52afd45
·
verified ·
1 Parent(s): 468fb31

Update origin to have the correct frontend url

Browse files
Files changed (1) hide show
  1. app/main.py +34 -32
app/main.py CHANGED
@@ -1,33 +1,35 @@
1
- from fastapi import FastAPI, Response
2
- from app.api.v1.api import api_router
3
- from fastapi.middleware.cors import CORSMiddleware
4
-
5
- from app.models.schemas import StandardResponse
6
-
7
- app = FastAPI(title="Cognisafe API")
8
-
9
- origins = ["*"]
10
-
11
- app.add_middleware(
12
- CORSMiddleware,
13
- allow_origins=origins, # or ["*"] for all origins (not recommended in prod)
14
- allow_credentials=True,
15
- allow_methods=["*"],
16
- allow_headers=["*"],
17
- )
18
-
19
- @app.get("/health")
20
- async def health_check():
21
- return {"status": "healthy"}
22
-
23
- @app.get("/helloworld", response_model=StandardResponse)
24
- def helloworld(response: Response) -> StandardResponse:
25
- """
26
- Returns helloworld as the standard response
27
- """
28
- response.status_code = 200
29
- response = StandardResponse(error=False, title="Hello World", status=200)
30
- return response
31
-
32
-
 
 
33
  app.include_router(api_router, prefix="/api/v1")
 
1
+ from fastapi import FastAPI, Response
2
+ from app.api.v1.api import api_router
3
+ from fastapi.middleware.cors import CORSMiddleware
4
+
5
+ from app.models.schemas import StandardResponse
6
+
7
+ app = FastAPI(title="Cognisafe API")
8
+
9
+ origins = [
10
+ "https://cognisafe.netlify.app"
11
+ ]
12
+
13
+ app.add_middleware(
14
+ CORSMiddleware,
15
+ allow_origins=origins, # or ["*"] for all origins (not recommended in prod)
16
+ allow_credentials=True,
17
+ allow_methods=["*"],
18
+ allow_headers=["*"],
19
+ )
20
+
21
+ @app.get("/health")
22
+ async def health_check():
23
+ return {"status": "healthy"}
24
+
25
+ @app.get("/helloworld", response_model=StandardResponse)
26
+ def helloworld(response: Response) -> StandardResponse:
27
+ """
28
+ Returns helloworld as the standard response
29
+ """
30
+ response.status_code = 200
31
+ response = StandardResponse(error=False, title="Hello World", status=200)
32
+ return response
33
+
34
+
35
  app.include_router(api_router, prefix="/api/v1")