{"url":"https://api.github.com/repos/simonw/datasette/issues/838","repository_url":"https://api.github.com/repos/simonw/datasette","labels_url":"https://api.github.com/repos/simonw/datasette/issues/838/labels{/name}","comments_url":"https://api.github.com/repos/simonw/datasette/issues/838/comments","events_url":"https://api.github.com/repos/simonw/datasette/issues/838/events","html_url":"https://github.com/simonw/datasette/issues/838","id":637395097,"node_id":"MDU6SXNzdWU2MzczOTUwOTc=","number":838,"title":"Incorrect URLs when served behind a proxy with base_url set","user":{"login":"tsibley","id":79913,"node_id":"MDQ6VXNlcjc5OTEz","avatar_url":"https://avatars.githubusercontent.com/u/79913?v=4","gravatar_id":"","url":"https://api.github.com/users/tsibley","html_url":"https://github.com/tsibley","followers_url":"https://api.github.com/users/tsibley/followers","following_url":"https://api.github.com/users/tsibley/following{/other_user}","gists_url":"https://api.github.com/users/tsibley/gists{/gist_id}","starred_url":"https://api.github.com/users/tsibley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tsibley/subscriptions","organizations_url":"https://api.github.com/users/tsibley/orgs","repos_url":"https://api.github.com/users/tsibley/repos","events_url":"https://api.github.com/users/tsibley/events{/privacy}","received_events_url":"https://api.github.com/users/tsibley/received_events","type":"User","user_view_type":"public","site_admin":false},"labels":[{"id":727708732,"node_id":"MDU6TGFiZWw3Mjc3MDg3MzI=","url":"https://api.github.com/repos/simonw/datasette/labels/bug","name":"bug","color":"ee0701","default":true,"description":null}],"state":"closed","locked":false,"assignees":[],"milestone":{"url":"https://api.github.com/repos/simonw/datasette/milestones/19","html_url":"https://github.com/simonw/datasette/milestone/19","labels_url":"https://api.github.com/repos/simonw/datasette/milestones/19/labels","id":6026070,"node_id":"MDk6TWlsZXN0b25lNjAyNjA3MA==","number":19,"title":"0.51","description":"A new visual design, plugin hooks for adding navigation options, better handling of binary data, URL building utility methods and better support for running Datasette behind a proxy.","creator":{"login":"simonw","id":9599,"node_id":"MDQ6VXNlcjk1OTk=","avatar_url":"https://avatars.githubusercontent.com/u/9599?v=4","gravatar_id":"","url":"https://api.github.com/users/simonw","html_url":"https://github.com/simonw","followers_url":"https://api.github.com/users/simonw/followers","following_url":"https://api.github.com/users/simonw/following{/other_user}","gists_url":"https://api.github.com/users/simonw/gists{/gist_id}","starred_url":"https://api.github.com/users/simonw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simonw/subscriptions","organizations_url":"https://api.github.com/users/simonw/orgs","repos_url":"https://api.github.com/users/simonw/repos","events_url":"https://api.github.com/users/simonw/events{/privacy}","received_events_url":"https://api.github.com/users/simonw/received_events","type":"User","user_view_type":"public","site_admin":false},"open_issues":0,"closed_issues":53,"state":"closed","created_at":"2020-10-23T19:42:45Z","updated_at":"2021-11-20T19:35:48Z","due_on":null,"closed_at":"2020-10-31T22:35:05Z"},"comments":14,"created_at":"2020-06-11T23:58:55Z","updated_at":"2021-11-20T19:35:48Z","closed_at":"2021-11-20T19:35:48Z","assignee":null,"author_association":"NONE","active_lock_reason":null,"sub_issues_summary":{"total":0,"completed":0,"percent_completed":0},"issue_dependencies_summary":{"blocked_by":0,"total_blocked_by":0,"blocking":0,"total_blocking":0},"body":"I'm running `datasette serve --config base_url:/foo/ …`, proxying to it with this Apache config:\r\n\r\n        ProxyPass /foo/ http://localhost:8001/ \r\n        ProxyPassReverse /foo/ http://localhost:8001/ \r\n\r\nand then accessing it via `https://example.com/foo/`.\r\n\r\nAlthough many of the URLs in the pages are correct (presumably because they either use absolute paths which include `base_url` or relative paths), the faceting and pagination links still use fully-qualified URLs pointing at `http://localhost:8001`.\r\n\r\nI looked into this a little in the source code, and it seems to be an issue anywhere `request.url` or `request.path` is used, as these contain the values for the request between the frontend (Apache) and backend (Datasette) server. Those properties are primarily used via the `path_with_…` family of utility functions and the `Datasette.absolute_url` method.","closed_by":{"login":"simonw","id":9599,"node_id":"MDQ6VXNlcjk1OTk=","avatar_url":"https://avatars.githubusercontent.com/u/9599?v=4","gravatar_id":"","url":"https://api.github.com/users/simonw","html_url":"https://github.com/simonw","followers_url":"https://api.github.com/users/simonw/followers","following_url":"https://api.github.com/users/simonw/following{/other_user}","gists_url":"https://api.github.com/users/simonw/gists{/gist_id}","starred_url":"https://api.github.com/users/simonw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simonw/subscriptions","organizations_url":"https://api.github.com/users/simonw/orgs","repos_url":"https://api.github.com/users/simonw/repos","events_url":"https://api.github.com/users/simonw/events{/privacy}","received_events_url":"https://api.github.com/users/simonw/received_events","type":"User","user_view_type":"public","site_admin":false},"reactions":{"url":"https://api.github.com/repos/simonw/datasette/issues/838/reactions","total_count":0,"+1":0,"-1":0,"laugh":0,"hooray":0,"confused":0,"heart":0,"rocket":0,"eyes":0},"timeline_url":"https://api.github.com/repos/simonw/datasette/issues/838/timeline","performed_via_github_app":null,"state_reason":"completed","pinned_comment":null}