Forward Slash at end of a router URL Problem
See original GitHub issueFirst Check
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar issue and didn’t find it.
- I searched the FastAPI documentation, with the integrated search.
- I already searched in Google “How to X in FastAPI” and didn’t find any information.
- I already read and followed all the tutorial in the docs and didn’t find an answer.
- I already checked if it is not related to FastAPI but to Pydantic.
- I already checked if it is not related to FastAPI but to Swagger UI.
- I already checked if it is not related to FastAPI but to ReDoc.
Commit to Help
- I commit to help with one of those options 👆
Example Code
router = APIRouter(
prefix="/care_line_people",
tags=["CareLinePeople"],
responses={404: {"description": "Not found"}},
)
@router.get('/add_identification_to_person')
def add_identification_to_person():
return '2'
@router.get('/add_identification_to_person_teste/')
def add_identification_to_person():
return '3'
Description
If I call bot endpoints locally it behaves as expected. Only method GET to the exact correct path, returns me what I want. Call GET with ‘/add_identification_to_person’, returns 2 and call ‘/add_identification_to_person_teste/’ (with dash incluse) returns 3. If I call GET with ‘/add_identification_to_person/’ it returns me 2 and if I call POST with ‘/add_identification_to_person’ it returns {details: method not allowed}.
The problema appears when I run this aplication on a EC2 in AWS configured with an Elastic Beanstalk (with Docker) and a Load Balancer where if I call any HTTP METHOD in a path ending with a ‘/’ it returns me that function normaly. So, if I call POST ‘/add_identification_to_person_teste’ it returns 3 and if a call ‘/add_identification_to_person/’ it returns 2.
I could found an explanation for this problem.
Operating System
Linux
Operating System Details
Both machines, mine and AWS are linux x86.
FastAPI Version
fastapi==0.79.0
Python Version
3.8
Additional Context
No response
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
@four43 sorry I wrote it fast and I didnt write it properly. It is a foward slash indeed
FYI that is a “forward slash” not a dash “-”