I am new to AWS. I'm trying to use Lambda to deploy a backend made with FastAPI and Mangum.
It works well if I use Lambda's 'Function URL', but if I use the 'AWS API Gateway' URL, it seems that somehow the path is not resolved correctly. What am I doing wrong?
I tested it with code similar to the following:
from fastapi import FastAPI
from mangum import Mangum
app = FastAPI()
# app = FastAPI(root_path = '/default_stage/myFunction')
handler = Mangum(app, lifespan="off")
# handler = Mangum(app, lifespan="off", api_gateway_base_path='/default_stage/myFunction')
@app.get("")
def f1():
return "f1"
@app.get("/")
def f2():
return "f2"
@app.get("/k")
def f3():
return "f3"
@app.get("/myFunction")
def f4():
return "f4"
@app.get("/myFunction/")
def f5():
return "f5"
@app.get("/myFunction/k")
def f6():
return "f6"
@app.get("/default_stage/myFunction")
def f7():
return "f7"
@app.get("/default_stage/myFunction/")
def f8():
return "f8"
@app.get("/default_stage/myFunction/k")
def f9():
return "f9"
And I tried FastAPI(root_path = '/default_stage/myFunction') or Mangum(app, lifespan="off", api_gateway_base_path='/default_stage/myFunction') and somehow it seems to be related to the solution, but I couldn't figure it out.
Also tried changing API Gateway > Develop > Routes here and there, but this didn't work either.
Any advice would be greatly appreciated, thanks.