added CORS middleware
Browse files
main.py
CHANGED
@@ -2,6 +2,7 @@ from datetime import datetime, timedelta
|
|
2 |
from typing import Annotated
|
3 |
from fastapi import Depends, FastAPI, HTTPException, status
|
4 |
from fastapi.security import OAuth2PasswordRequestForm
|
|
|
5 |
from sqlmodel import Session, select
|
6 |
from config import settings
|
7 |
|
@@ -11,6 +12,19 @@ from core import utils, crud
|
|
11 |
|
12 |
app = FastAPI()
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
app.include_router(profile.router)
|
15 |
app.include_router(users.router)
|
16 |
app.include_router(sites.router)
|
|
|
2 |
from typing import Annotated
|
3 |
from fastapi import Depends, FastAPI, HTTPException, status
|
4 |
from fastapi.security import OAuth2PasswordRequestForm
|
5 |
+
from fastapi.middleware.cors import CORSMiddleware
|
6 |
from sqlmodel import Session, select
|
7 |
from config import settings
|
8 |
|
|
|
12 |
|
13 |
app = FastAPI()
|
14 |
|
15 |
+
origins = [
|
16 |
+
"http://localhost",
|
17 |
+
"http://localhost:3000",
|
18 |
+
]
|
19 |
+
|
20 |
+
app.add_middleware(
|
21 |
+
CORSMiddleware,
|
22 |
+
allow_origins=origins,
|
23 |
+
allow_credentials=True,
|
24 |
+
allow_methods=["*"],
|
25 |
+
allow_headers=["*"],
|
26 |
+
)
|
27 |
+
|
28 |
app.include_router(profile.router)
|
29 |
app.include_router(users.router)
|
30 |
app.include_router(sites.router)
|
models.py
CHANGED
@@ -61,8 +61,8 @@ class UserUpdate(SQLModel):
|
|
61 |
email: str | None = None
|
62 |
full_name: str | None = None
|
63 |
password: str | None = None
|
64 |
-
disabled: bool | None =
|
65 |
-
is_su: bool | None =
|
66 |
|
67 |
class UserPublicMe(UserBase):
|
68 |
id: int
|
|
|
61 |
email: str | None = None
|
62 |
full_name: str | None = None
|
63 |
password: str | None = None
|
64 |
+
disabled: bool | None = False
|
65 |
+
is_su: bool | None = False
|
66 |
|
67 |
class UserPublicMe(UserBase):
|
68 |
id: int
|