boyinfuture commited on
Commit
89d6457
·
1 Parent(s): 906fd4c

editing the main file

Browse files
Files changed (1) hide show
  1. backend/main.py +6 -14
backend/main.py CHANGED
@@ -66,15 +66,13 @@
66
 
67
 
68
 
69
-
70
-
71
  from fastapi import FastAPI, Depends, HTTPException
72
  from fastapi.middleware.cors import CORSMiddleware
73
  from sqlalchemy.orm import Session
74
  from sqlalchemy import desc
75
  from uuid import UUID
76
  from typing import List
77
- import models.analysis_job as model # Make sure this is db_models, not models
78
  import schemas
79
  from core.database import SessionLocal, engine
80
  from tasks.main_task import run_full_analysis
@@ -86,20 +84,14 @@ app = FastAPI(
86
  version="0.1.0",
87
  )
88
 
89
- # --- THIS IS THE CRITICAL FIX FOR DEPLOYMENT ---
90
- # Define the specific domains that are allowed to access our API
91
- allowed_origins = [
92
- "http://localhost:5173", # For your local development
93
- "https://quantitative-analysis-platform.vercel.app" # Your live Vercel URL,
94
- "quantitative-analysis-platform-git-main-aadarsh-rajs-projects.vercel.app",
95
- "quantitative-analysis-platform-o6n52ntyg-aadarsh-rajs-projects.vercel.app",
96
- ]
97
-
98
  app.add_middleware(
99
  CORSMiddleware,
100
- allow_origins=allowed_origins,
101
  allow_credentials=True,
102
- allow_methods=["GET", "POST", "OPTIONS"],
103
  allow_headers=["*"],
104
  )
105
  # --- END OF FIX ---
 
66
 
67
 
68
 
 
 
69
  from fastapi import FastAPI, Depends, HTTPException
70
  from fastapi.middleware.cors import CORSMiddleware
71
  from sqlalchemy.orm import Session
72
  from sqlalchemy import desc
73
  from uuid import UUID
74
  from typing import List
75
+ import models.analysis_job as model
76
  import schemas
77
  from core.database import SessionLocal, engine
78
  from tasks.main_task import run_full_analysis
 
84
  version="0.1.0",
85
  )
86
 
87
+ # --- THIS IS THE FINAL FIX ---
88
+ # This configuration allows your Vercel app and all its preview deployments
89
+ # to communicate with the backend, as well as your local development server.
 
 
 
 
 
 
90
  app.add_middleware(
91
  CORSMiddleware,
92
+ allow_origin_regex=r"https?://.*\.vercel\.app|http://localhost:5173",
93
  allow_credentials=True,
94
+ allow_methods=["*"],
95
  allow_headers=["*"],
96
  )
97
  # --- END OF FIX ---