-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
46 lines (38 loc) · 1.07 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from wolfram_sigma_backend.app.auth.auth import auth_backend, fastapi_users
from wolfram_sigma_backend.app.domain.auth import UserCreate, UserRead
from wolfram_sigma_backend.app.web_api.routers import routers
app = FastAPI()
app.include_router(
fastapi_users.get_auth_router(auth_backend),
prefix="/auth/jwt",
tags=["auth"],
)
app.include_router(
fastapi_users.get_register_router(UserRead, UserCreate),
prefix="/auth",
tags=["auth"],
)
for router in routers:
app.include_router(router)
origins = [
"http://localhost:8000",
"http://localhost",
"http://127.0.0.1",
"http://127.0.0.1:4200",
"http://localhost:4200",
]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["GET", "POST", "OPTIONS", "DELETE", "PATCH", "PUT"],
allow_headers=[
"Access-Control-Allow-Headers",
"Content-Type",
"Authorization",
"Access-Control-Allow-Origin",
"Set-Cookie",
],
)