db9624822b
Resolved conflict by keeping env var approach from main and updating the default to include both localhost:3000 and localhost:3001. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
32 lines
717 B
Python
32 lines
717 B
Python
import os
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from .database import engine, Base
|
|
from .routes import users, purchases, stats, history
|
|
|
|
Base.metadata.create_all(bind=engine)
|
|
|
|
app = FastAPI(title="BTC Portfolio API")
|
|
|
|
origins = os.getenv("ALLOWED_ORIGINS", "http://localhost:3000,http://localhost:3001").split(",")
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=origins,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.include_router(users.router)
|
|
app.include_router(purchases.router)
|
|
app.include_router(stats.router)
|
|
app.include_router(history.router)
|
|
|
|
|
|
@app.get("/")
|
|
def root():
|
|
return {"message": "BTC Portfolio API"}
|