mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-22 23:31:12 +02:00
- Improve CORS config readability by breaking nested os.getenv() into explicit fallback steps (_default_cors_origin -> _cors_origins_str) - Remove duplicate import os statement - Consolidate all Celery task imports at module level - Remove inline imports from function bodies
This commit is contained in:
parent
f770617d9f
commit
24b95e5a6f
2 changed files with 8 additions and 11 deletions
|
|
@ -138,7 +138,8 @@ class Config:
|
|||
# CORS Configuration
|
||||
# Comma-separated list of allowed origins, defaults to frontend URL
|
||||
# Note: Wildcard "*" is not allowed when allow_credentials=True
|
||||
_cors_origins_str = os.getenv("CORS_ORIGINS", os.getenv("NEXT_FRONTEND_URL", "http://localhost:3000"))
|
||||
_default_cors_origin = os.getenv("NEXT_FRONTEND_URL", "http://localhost:3000")
|
||||
_cors_origins_str = os.getenv("CORS_ORIGINS", _default_cors_origin)
|
||||
CORS_ORIGINS = [origin.strip() for origin in _cors_origins_str.split(",") if origin.strip()]
|
||||
|
||||
# Google OAuth
|
||||
|
|
|
|||
|
|
@ -26,7 +26,12 @@ from app.schemas import (
|
|||
)
|
||||
from app.users import current_active_user
|
||||
from app.utils.check_ownership import check_ownership
|
||||
from app.tasks.celery_tasks.document_tasks import process_file_upload_task
|
||||
from app.tasks.celery_tasks.document_tasks import (
|
||||
process_crawled_url_task,
|
||||
process_extension_document_task,
|
||||
process_file_upload_task,
|
||||
process_youtube_video_task,
|
||||
)
|
||||
|
||||
try:
|
||||
asyncio.set_event_loop_policy(asyncio.DefaultEventLoopPolicy())
|
||||
|
|
@ -34,8 +39,6 @@ except RuntimeError as e:
|
|||
print("Error setting event loop policy", e)
|
||||
pass
|
||||
|
||||
import os
|
||||
|
||||
os.environ["UNSTRUCTURED_HAS_PATCHED_LOOP"] = "1"
|
||||
|
||||
|
||||
|
|
@ -53,10 +56,6 @@ async def create_documents(
|
|||
await check_ownership(session, SearchSpace, request.search_space_id, user)
|
||||
|
||||
if request.document_type == DocumentType.EXTENSION:
|
||||
from app.tasks.celery_tasks.document_tasks import (
|
||||
process_extension_document_task,
|
||||
)
|
||||
|
||||
for individual_document in request.content:
|
||||
# Convert document to dict for Celery serialization
|
||||
document_dict = {
|
||||
|
|
@ -70,14 +69,11 @@ async def create_documents(
|
|||
document_dict, request.search_space_id, str(user.id)
|
||||
)
|
||||
elif request.document_type == DocumentType.CRAWLED_URL:
|
||||
from app.tasks.celery_tasks.document_tasks import process_crawled_url_task
|
||||
|
||||
for url in request.content:
|
||||
process_crawled_url_task.delay(
|
||||
url, request.search_space_id, str(user.id)
|
||||
)
|
||||
elif request.document_type == DocumentType.YOUTUBE_VIDEO:
|
||||
from app.tasks.celery_tasks.document_tasks import process_youtube_video_task
|
||||
|
||||
for url in request.content:
|
||||
process_youtube_video_task.delay(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue