Is is possible to set up FastApi in such a way that a redirect response will not automatically be followed? Assume I have the following functions:
from fastapi import FastAPI, Response
from fastapi.responses import RedirectResponse
fast_api_app = FastAPI()
@router.get('/some_url')
async def redirect_function():
redirect_response = RedirectResponse('/redirect_url', status_code=303)
return redirect_response
@router.get('/redirect_url')
async def redirected_function():
response = Response(status_code=200)
return response
When I use the requests library or the FastAPI test client to access "/some_url" I always get automatically redirected to "/redirect_url" and the response's status code will be 200. My wished behavior would be that the response status code is 303 and I am responsible for the redirection.