Update vite to have proper routing for api
This commit is contained in:
parent
02d6ecd28c
commit
4842cef07a
5 changed files with 37 additions and 29 deletions
16
api/index.py
16
api/index.py
|
|
@ -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"}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue