-
-
Notifications
You must be signed in to change notification settings - Fork 702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Errors when using table filters behind a proxy #1883
Comments
Great catch, thanks! |
If you view source on that page the HTML looks correct: <form class="filters" action="/prefix/fixtures/binary_data" method="get"> (I just added a test that confirms this too.) But... it looks like the bug is in the redirection code. https://datasette-apache-proxy-demo.datasette.io/prefix/fixtures/binary_data?_filter_column=rowid&_filter_op=exact&_filter_value=1&_sort=rowid returns the following:
Which is incorrect. |
I tried adding this test but it passed! I expected it to fail: def test_base_url_affects_filter_redirects(app_client_base_url_prefix):
response = app_client_base_url_prefix.get(
"/prefix/fixtures/binary_data?_filter_column=rowid&_filter_op=exact&_filter_value=1&_sort=rowid"
)
assert response.status == 302
assert (
response.headers["location"]
== "/prefix/fixtures/binary_data?_sort=rowid&rowid__exact=1"
) |
Relevant code: datasette/datasette/views/table.py Lines 227 to 249 in bbaab3b
|
datasette/datasette/utils/__init__.py Lines 273 to 286 in bbaab3b
|
Is there a chance that it's Apache that's messing with that datasette/demos/apache-proxy/000-default.conf Lines 7 to 13 in bbaab3b
|
https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypass includes this note:
|
I modified that config file to have this line instead:
And then deployed it by running:
This does NOT seem to have fixed the bug:
https://datasette-apache-proxy-demo.datasette.io/prefix/-/versions seems to confirm that this is the latest deployed version (0.63), so it looks like the deploy worked. |
https://datasette-apache-proxy-demo.datasette.io/prefix/-/asgi-scope is useful: It confirms that
|
Modifying that test to the following does indeed cause a failure: def test_base_url_affects_filter_redirects(app_client_base_url_prefix):
response = app_client_base_url_prefix.get(
"/fixtures/binary_data?_filter_column=rowid&_filter_op=exact&_filter_value=1&_sort=rowid"
)
assert response.status == 302
assert (
response.headers["location"]
== "/prefix/fixtures/binary_data?_sort=rowid&rowid__exact=1"
) |
This time deployed with:
To ensure the exact commit with the fix. And that fixed it!
|
I released that fix in Datasette 0.63.1: https://docs.datasette.io/en/stable/changelog.html#v0-63-1 |
Amazing - thank you for fixing and releasing that so quickly and for showing your process! <3 |
Using datasette==0.63 table filters do not respect the
base_url
setting as described hereTo reproduce, go to:
https://datasette-apache-proxy-demo.datasette.io/prefix/fixtures/binary_data
Then use the table filter buttons.
The
/prefix/
is dropped, resulting in URL not found:https://datasette-apache-proxy-demo.datasette.io/fixtures/binary_data?_sort=rowid&rowid__exact=1
The text was updated successfully, but these errors were encountered: