Change remote_addr to 127.0.0.1 using proxy

I need to use proxy (preferably mitmweb) to 127.0.0.1 to get access to a restricted webpage. I am new to this and don’t know exactly what to do. Just adding a header with remote_addr : 127.0.0.1 isn’t working.

The code which gives access -

if request.remote_addr != '127.0.0.1':
            return abort(403)

Any help would be appreciated.