cors?
Browse files- App/app.py +15 -10
App/app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
from fastapi import FastAPI
|
2 |
-
from
|
|
|
3 |
from .Users.UserRoutes import user_router
|
4 |
from .Webhooks.webhookRoute import webhook_router
|
5 |
from .Subscriptions.SubscriptionRoutes import subscription_router
|
@@ -12,6 +13,15 @@ from .Messages.MessagesRoute import message_router
|
|
12 |
|
13 |
app = FastAPI()
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
@app.on_event("startup")
|
17 |
async def startup_event():
|
@@ -24,6 +34,7 @@ async def landing_page():
|
|
24 |
return {"code": 200, "message": "still running"}
|
25 |
|
26 |
|
|
|
27 |
app.include_router(user_router)
|
28 |
app.include_router(webhook_router)
|
29 |
app.include_router(subscription_router)
|
@@ -33,14 +44,8 @@ app.include_router(portal_router)
|
|
33 |
app.include_router(metrics_router)
|
34 |
app.include_router(message_router)
|
35 |
|
36 |
-
|
37 |
-
if __name__ == "__main__":
|
38 |
-
import uvicorn
|
39 |
-
|
40 |
-
# Run the FastAPI app located at App.app:app
|
41 |
-
uvicorn.run(app, host="0.0.0.0", port=8000)
|
42 |
-
|
43 |
-
|
44 |
# if __name__ == "__main__":
|
45 |
-
#
|
|
|
|
|
46 |
# uvicorn.run(app, host="0.0.0.0", port=8000)
|
|
|
1 |
from fastapi import FastAPI
|
2 |
+
from fastapi.middleware.cors import CORSMiddleware
|
3 |
+
from tortoise import Tortoise
|
4 |
from .Users.UserRoutes import user_router
|
5 |
from .Webhooks.webhookRoute import webhook_router
|
6 |
from .Subscriptions.SubscriptionRoutes import subscription_router
|
|
|
13 |
|
14 |
app = FastAPI()
|
15 |
|
16 |
+
# Configure CORS to allow all origins
|
17 |
+
app.add_middleware(
|
18 |
+
CORSMiddleware,
|
19 |
+
allow_origins=["*"], # Allows all origins
|
20 |
+
allow_credentials=True, # Allows cookies and authentication headers
|
21 |
+
allow_methods=["*"], # Allows all HTTP methods (GET, POST, PUT, DELETE, etc.)
|
22 |
+
allow_headers=["*"], # Allows all headers
|
23 |
+
)
|
24 |
+
|
25 |
|
26 |
@app.on_event("startup")
|
27 |
async def startup_event():
|
|
|
34 |
return {"code": 200, "message": "still running"}
|
35 |
|
36 |
|
37 |
+
# Include routers
|
38 |
app.include_router(user_router)
|
39 |
app.include_router(webhook_router)
|
40 |
app.include_router(subscription_router)
|
|
|
44 |
app.include_router(metrics_router)
|
45 |
app.include_router(message_router)
|
46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
# if __name__ == "__main__":
|
48 |
+
# import uvicorn
|
49 |
+
|
50 |
+
# # Run the FastAPI app located at App.app:app
|
51 |
# uvicorn.run(app, host="0.0.0.0", port=8000)
|