Skip to content

Commit b0c5448

Browse files
committed
🩹 Pagination returns the HTTP protocol in a production environment, but it should return the HTTPS protocol.
Pagination returns the HTTP protocol in a production environment, but it should return the HTTPS protocol.
1 parent 8e304e1 commit b0c5448

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

‎rest_framework/pagination.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,16 @@ def get_page_size(self, request):
275275
def get_next_link(self):
276276
if not self.page.has_next():
277277
return None
278-
url = self.request.build_absolute_uri()
278+
279+
current_protocol = self.request.scheme
280+
current_host = self.request.get_host()
281+
current_path = self.request.path
279282
page_number = self.page.next_page_number()
280-
return replace_query_param(url, self.page_query_param, page_number)
283+
param = self.page_query_param
284+
285+
url = f'{current_protocol}://{current_host}{current_path}?{param}={page_number}'
286+
287+
return url
281288

282289
def get_previous_link(self):
283290
if not self.page.has_previous():

0 commit comments

Comments
 (0)