feat: added another 'Date' expose-headers for outline api clients (#27221)
Exposed the Date header on the outline api so clients can accurately compute times relative to the dates returned by the API; this was previously done with the course API (#26979) Browser time is notoriously unreliable for this, especially for a Learner-facing countdown call-to-action based on the access expiration date. (REV-2126) Using the Date header for this allows the client to make use of information that is already sent, does not require additional calls nor modifying the API, and could be generalized to more or all our APIs without modifying them.
This commit is contained in:
@@ -213,3 +213,13 @@ def reset_course_deadlines(request):
|
||||
|
||||
referrer = request.META.get('HTTP_REFERER')
|
||||
return redirect(referrer) if referrer else HttpResponse()
|
||||
|
||||
|
||||
def expose_header(header, response):
|
||||
"""
|
||||
Add a header name to Access-Control-Expose-Headers to allow client code to access that header's value
|
||||
"""
|
||||
exposedHeaders = response.get('Access-Control-Expose-Headers', '')
|
||||
exposedHeaders += f', {header}' if exposedHeaders else header
|
||||
response['Access-Control-Expose-Headers'] = exposedHeaders
|
||||
return response
|
||||
|
||||
Reference in New Issue
Block a user