neurobagel / api

https://api.neurobagel.org/
MIT License
4 stars 4 forks source link

Routes without trailing slash cause `307` redirect which breaks reverse proxies via paths #327

Closed alyssadai closed 1 month ago

alyssadai commented 1 month ago

Context

Depending on whether a route in FastAPI is defined with or without a trailing slash, FastAPI by default tries to automatically redirect the alternative to the URL with the / added or removed (see examples below).

Right now:

Some consequences:

This hasn't been an issue for us in the past because:

Rather than the current redirect behaviour (which is also less efficient due to multiple round trips), we probably want one of the following outcomes:

Option 1:

(can be achieved via two route decorators)

Option 2:

(can be achieved w/ the redirect_slashes parameter of the FastAPI and/or APIRouter class)

Decisions

Relevant issues:

alyssadai commented 1 month ago

PR https://github.com/neurobagel/api/pull/328 is ready to merge, but will wait for the PR for https://github.com/neurobagel/query-tool/issues/234 to maintain compatibility with the query tool.

neurobagel-bot[bot] commented 1 month ago

:rocket: Issue was released in v0.3.0 :rocket: