0

I have Django project hosted on Heroku

There's a web-application and a Django REST API.

I'm using SECURE_SSL_REDIRECT and SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') to redirect all http traffic to https.

The web-application is happy. If I try to use a http link, it redirects to https, and I can use forms, etc.

For the Django REST API, if I try a http link and a POST request, it redirects successfully to https but the method becomes a GET and the API requests the request (because it is meant to be a POST).

I do not know if this is expected behaviour, or if this is a Heroku specific thing. If it's expected for redirects, I'd appreciate to understand why (from a technical point).

And or if there is a solution.

ShibbySham
  • 71
  • 1
  • 2
  • 5
  • you will find it here https://stackoverflow.com/questions/51343523/django-rest-framework-post-request-returns-method-get-not-allowed – Rafi Aug 18 '20 at 09:57
  • Thanks so much! Your searching skills are much better than mine. So the solution is to recognize `www` in our URL definitions as well? – ShibbySham Aug 19 '20 at 10:11
  • Lol thank you, just keep practice searching and you will get there:) yes, that way there is no redirection. – Rafi Aug 19 '20 at 10:52

0 Answers0