When I POST a new resource to my RESTful Tastypie API, I create a resource and get a 201 response like this:
HTTP/1.1 201 CREATED
Content-Type: text/html; charset=utf-8
Date: Wed, 19 Sep 2012 01:02:48 GMT
Location: http://example.com/api/v1/resource/12/
Server: gunicorn/0.14.6
Content-Length: 0
Connection: keep-alive
Great! Except I posted to an HTTPS URL and would like to get a HTTPS Location
header back. How can I configure tastypie to do this?
Addition
I am using some middleware to force SSL, but I don't think it is the cause of this issue. Here it is anyway:
class SSLifyMiddleware(object):
# Derived from https://github.com/rdegges/django-sslify
def process_request(self, request):
if not any((not settings.FORCE_SSL, request.is_secure(), request.META.get('HTTP_X_FORWARDED_PROTO', '') == 'https')):
url = request.build_absolute_uri(request.get_full_path())
secure_url = url.replace('http://', 'https://')
return HttpResponseRedirect(secure_url)
Addition
This is a Heroku app.