Add root '/' redirect to /app and corresponding test#12
Open
Add root '/' redirect to /app and corresponding test#12
/app and corresponding test#12Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a redirect from the root path to the '/app' endpoint and adds a corresponding test case to verify the behavior. The reviewer suggests using a 301 Moved Permanently status code instead of 302 Found to improve SEO and caching, along with updating the test assertions to match this change.
|
|
||
| @app.get("/", include_in_schema=False) | ||
| def root_redirect() -> RedirectResponse: | ||
| return RedirectResponse("/app", status_code=status.HTTP_302_FOUND) |
Contributor
There was a problem hiding this comment.
Using 302 Found indicates a temporary redirect. Given that the root is being redirected to the main application entry point, this is likely a permanent change. It's better practice to use a permanent redirect status code like 301 Moved Permanently. This helps with SEO and allows browsers and other clients to cache the redirect.
Suggested change
| return RedirectResponse("/app", status_code=status.HTTP_302_FOUND) | |
| return RedirectResponse("/app", status_code=status.HTTP_301_MOVED_PERMANENTLY) |
| with stack["TestClient"](app, base_url="https://testserver") as client: | ||
| response = client.get("/", follow_redirects=False) | ||
|
|
||
| assert response.status_code == 302 |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
/appfor a smoother entry point.Description
/inapp/main.pythat returnsRedirectResponse("/app", status_code=status.HTTP_302_FOUND)and importstatusandRedirectResponse.test_root_route_redirects_to_appintests/test_auth_requester.pyto validate the redirect.Testing
tests/test_auth_requester.py::test_root_route_redirects_to_appand ran the test suite; the new test passed with the existing tests.Codex Task