close
0

Python/FastAPI: how can I get headers or a specific header from my backend API?

avatar
asked 27-08-2022

1 Answers


0

Try

def token_required(func):
    @wraps(func)
    async def wrapper(*args, request: Request, **kwargs):
        my_header = request.headers.get('my-header')
        # my_header will be now available in decorator
        return await func(*args, request, **kwargs)
    return wrapper
avatar
answered 27-08-2022