Update vite to have proper routing for api

This commit is contained in:
Joey Yakimowich-Payne 2023-08-10 10:26:16 -06:00
commit 4842cef07a
No known key found for this signature in database
GPG key ID: 6BFE655FA5ABD1E1
5 changed files with 37 additions and 29 deletions

View file

@ -1,25 +1,13 @@
from dotenv import dotenv_values
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from api.db.engine import engine
config = dotenv_values(".env")
app = FastAPI()
app = FastAPI(root_path="/api")
origins = ["http://localhost", config["VITE_APP_URL"]]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get("/api/python")
@app.get("/v1/python")
def hello_world():
return {"message": "Hello World"}