WP_List_Table $current_url points to my actual host rather than the reverse proxy host

I am a novice on the wordpress framework and I am currently using wordpress behind a reverse proxy. Like follows.

Reverse Proxy Domain = https://example.com
My actual Domain = https://example-herokuapp.com

Issue :

  • In wp-admin dashboard when i try to filter posts like orderby date or comments etc in the admin panel. I get a 404 page.
  • Thats because the links are pointing to my actual host ie https://example-herokuapp.com rather than my reverse proxy which is https://example.com

Reason :

  • This seems to be because of the $ current_url attribute wp_list_table which is called from wp-admin/edit.php

  • The current url is defined as follows

    $  current_url = set_url_scheme( 'http://' . $  _SERVER['HTTP_HOST'] . $  _SERVER['REQUEST_URI'] );
  • I came across a very old bug/issue from wordpress https://core.trac.wordpress.org/ticket/16858 , which seems to address this very same problem.

  • It essentially uses a self_admin_url to overcome this issue.

  • The above mentioned patch (https://core.trac.wordpress.org/attachment/ticket/16858/16858.patch) is not available on 5.5.3 (LTS).However the self_admin_url method is available under wp-admin/includes.

Question :

  • How do i change this $ current_url to use self_admin_url().? Should i override $ _Server[‘HTTP_HOST’] in wp-config ? or what is the best practise to change things like this .

  • Or is there a better way to ensure my admin links point to my proxy host rather than my actual host ?

Thanks in advance.