Some endpoints only work with a trailing slash
See original GitHub issueBug Description
Some of our endpoints only work if they end with a trailing slash, i.e. /api/v1/organization/
works, but /api/v1/organization
results in a 404
Steps to Reproduce
- Run
nox -s api
- Try to navigate to
localhost:8080/api/v1/organization
, which will give a 404 - Navigate to
localhost:8080/api/v1/organization/
which should work as expected
Expected behavior
For endpoints even without a trailing slash to work properly
Screenshots
If applicable, add screenshots to help explain your problem.
Environment
- Version: main
- OS: OSX
- Python Version: 3.8
- Docker Version: 20.10.14
Additional context
Note that /api/v1/health
does work, so this is probably a problem with dynamically generating the endpoints.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
RESTful URI trailing slash or no trailing slash - Stack Overflow
Every URI (ending with slash or not) will point to a resource. As far as I know there is no specific recommendation to...
Read more >Should You Have a Trailing Slash at the End of URLs? - Ahrefs
A trailing slash is a forward slash (“/”) placed at the end of a URL such as domain.com/ or domain.com/page/. But should you...
Read more >Deprecate trailing slash match and change default value from ...
Whether to match to URLs irrespective of the presence of a trailing slash. If enabled a method mapped to "/users" also matches to...
Read more >Using a Slash Character in Spring URLs - Baeldung
In this tutorial, we'll show some common solutions and recommendations for handling URLs with slashes in Spring. We'll also see why we shouldn't ......
Read more >10.3. Routing — Fundamentals of Web Programming
The canonical URL for the projects endpoint has a trailing slash. It's similar to a folder in a file system. If you access...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The reason is the
/
in the root routes like here. as opposed to the no trailing/
like in health.Changing to no
/
like@router.get("", response_model=List[resource_model], name="List")
makeslocalhost:8080/api/v1/organization
work, butlocalhost:8080/api/v1/organization/
will no longer work.I thought newer versions of FastAPI, including the version being used in fidesctl, were supposed to automatically handle this. I am not sure what that isn’t happening.
I agree with the solution @TheAndrewJackson came up with, as I ended up at the exact same GitHub issue haha
I think the fidesops implementation is the right way to go 👍 🦖