Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

route.get("/") #1648

Closed
curtiscook opened this issue Jun 30, 2020 · 7 comments
Closed

route.get("/") #1648

curtiscook opened this issue Jun 30, 2020 · 7 comments
Labels
question Question or problem question-migrate

Comments

@curtiscook
Copy link

Hi,

Very small issue

In the docs it is recommended to do

@route.get("/")

for the base path on a router (or endpoint). However, this causes a 307 redirect to include the trailing slash, which is inconsistent with the standard behavior of no trailing slash.

You can work around the issue with

@route.get("/?") but @route.get() is unsupported

Maybe it would be helpful to
a) update the docs around this behavior
b) support @route.get() with no parameters ?

Why it's relevant: often times clients will drop headers on a redirect, which will drop the authorization header.

@curtiscook curtiscook added the question Question or problem label Jun 30, 2020
@David-Lor
Copy link

Have you tried empty string (@route.get(""))? I've used it as a workaround for the 307-redirect "issue".

@curtiscook
Copy link
Author

That could work too but (IMO) looks strange.

I think this is mostly a documentation issue

@curtiscook
Copy link
Author

FYI @tiangolo it looks like regex in the path is broken as of the latest release

@route.get("/?") 

now returns a 404. Could be related to a starlette change

@tiangolo
Copy link
Owner

tiangolo commented Dec 8, 2020

@curtiscook yeah @router.get("") would be the way to go, as @David-Lor says.

I agree it looks strange, but @router.get() seems even stranger (at least to me) and would be more difficult to handle internally.

It is supported only for those special cases but is not recommended.

@curtiscook
Copy link
Author

@curtiscook yeah @router.get("") would be the way to go, as @David-Lor says.

I agree it looks strange, but @router.get() seems even stranger (at least to me) and would be more difficult to handle internally.

It is supported only for those special cases but is not recommended.

Yeah, I think the only thing to do here would be to update the docs to be a little more clear?

@router.get("/") doesn't match @router.get("/foo") with regards to the trailing slash

@github-actions github-actions bot removed the answered label Dec 9, 2020
@nikhilshinday
Copy link

Hey @curtiscook, check out my solution here. The annotator-for-annotators solution should allow for you to enter use either "/" or "/foo" and have the alternative route included.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2022

Assuming the original need was handled, this will be automatically closed now. But feel free to add more comments or create new issues or PRs.

@github-actions github-actions bot closed this as completed Nov 5, 2022
@tiangolo tiangolo reopened this Feb 28, 2023
@github-actions github-actions bot removed the answered label Feb 28, 2023
Repository owner locked and limited conversation to collaborators Feb 28, 2023
@tiangolo tiangolo converted this issue into discussion #7513 Feb 28, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
question Question or problem question-migrate
Projects
None yet
Development

No branches or pull requests

4 participants