Skip to content

Commit

Permalink
Add CORS middleware for allowing all origins to make requests
Browse files Browse the repository at this point in the history
  • Loading branch information
ntohidi committed May 10, 2024
1 parent 20ef255 commit aa126e4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
from crawl4ai.database import get_total_count, clear_db
import os
import uuid
# Import the CORS middleware
from fastapi.middleware.cors import CORSMiddleware


# Task management
tasks = {}
Expand All @@ -25,6 +28,16 @@

app = FastAPI()

# CORS configuration
origins = ["*"] # Allow all origins
app.add_middleware(
CORSMiddleware,
allow_origins=origins, # List of origins that are allowed to make requests
allow_credentials=True,
allow_methods=["*"], # Allows all methods
allow_headers=["*"], # Allows all headers
)

# Mount the pages directory as a static directory
app.mount("/pages", StaticFiles(directory=__location__ + "/pages"), name="pages")

Expand Down

0 comments on commit aa126e4

Please sign in to comment.