Delete header in django rest framework response

后端 未结 1 698
北恋
北恋 2021-01-21 06:56

I\'m trying to delete Server header from django rest framework response, but I didn\'t find an easy way, so I create a middleware to delete it.

This is my f

相关标签:
1条回答
  • 2021-01-21 07:21

    I just had the exact same problem. Your approach with

    del response['Server']
    

    Is correct!

    However, you need to move your middleware to be the first. As other middlewares will add headers after the response is constructed, so the order of application is bottom-up. Your middleware has to be the first one to have the "last word".

    0 讨论(0)
提交回复
热议问题