I have an API working just fine on one URL (it returns a nice 201 CREATED):
curl -d @scan.json -H "Content-Type: application/json" -u admin -i -v "https://vincentle.pythonanywhere.com/api/beacons/"
But when I try to perform the same request without the SSL:
curl -d @scan.json -H "Content-Type: application/json" -u admin -i -v "http://vincentle.pythonanywhere.com/api/beacons/"
I get a 301 Moved Permanently
response.
I have tried two fixes:
I defined a URL without the trailing slash (after reading this post). This is not the solution, request with, or without slash will return 301.
I added a header "
HTTP_X_FORWARDED_PROTO: https
" in my request, as I have the lineSECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
in my settings. This isn't the solution either.
Any idea?