-
-
Notifications
You must be signed in to change notification settings - Fork 700
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
.json and .csv exports fail to apply base_url #1091
Comments
Hmm... it's not just the <p class="export-links">This data as
<a href="/corpora-metadata/REF_PARSE_EXCEPTION_TYPES.json">json</a>,
<a href="/corpora-metadata/REF_PARSE_EXCEPTION_TYPES.csv?_size=max">CSV</a> (
<a href="#export">advanced</a>)
</p>
<div class="table-wrapper">
<table class="rows-and-columns">
<thead>
<tr>
<th class="col-Link" scope="col" data-column="Link" data-column-type="" data-column-not-null="0" data-is-pk="0">
Link
</th>
<th class="col-rowid" scope="col" data-column="rowid" data-column-type="integer" data-column-not-null="0" data-is-pk="1">
<a href="/corpora-metadata/REF_PARSE_EXCEPTION_TYPES?_sort_desc=rowid" rel="nofollow">rowid ▼</a>
</th>
<th class="col-PARSE_EXCEPTION_ID" scope="col" data-column="PARSE_EXCEPTION_ID" data-column-type="INTEGER" data-column-not-null="0" data-is-pk="0">
<a href="/corpora-metadata/REF_PARSE_EXCEPTION_TYPES?_sort=PARSE_EXCEPTION_ID" rel="nofollow">PARSE_EXCEPTION_ID</a>
</th>
<th class="col-PARSE_EXCEPTION_DESCRIPTION" scope="col" data-column="PARSE_EXCEPTION_DESCRIPTION" data-column-type="VARCHAR(128)" data-column-not-null="0" data-is-pk="0">
<a href="/corpora-metadata/REF_PARSE_EXCEPTION_TYPES?_sort=PARSE_EXCEPTION_DESCRIPTION" rel="nofollow">PARSE_EXCEPTION_DESCRIPTION</a>
</th>
</tr>
</thead>
<tbody>
<tr>
<td class="col-Link type-pk">
<a href="/datasette/corpora-metadata/REF_PARSE_EXCEPTION_TYPES/1">1</a>
</td>
<td class="col-rowid type-int">1</td>
<td class="col-PARSE_EXCEPTION_ID type-int">0</td>
<td class="col-PARSE_EXCEPTION_DESCRIPTION type-str">RUNTIME</td>
</tr>
<tr>
<td class="col-Link type-pk">
<a href="/datasette/corpora-metadata/REF_PARSE_EXCEPTION_TYPES/2">2</a>
</td>
<td class="col-rowid type-int">2</td>
<td class="col-PARSE_EXCEPTION_ID type-int">1</td>
<td class="col-PARSE_EXCEPTION_DESCRIPTION type-str">ENCRYPTION</td>
</tr>
<tr>
<td class="col-Link type-pk">
<a href="/datasette/corpora-metadata/REF_PARSE_EXCEPTION_TYPES/3">3</a>
</td>
<td class="col-rowid type-int">3</td>
<td class="col-PARSE_EXCEPTION_ID type-int">2</td>
<td class="col-PARSE_EXCEPTION_DESCRIPTION type-str">ACCESS_PERMISSION</td>
</tr>
<tr>
<td class="col-Link type-pk">
<a href="/datasette/corpora-metadata/REF_PARSE_EXCEPTION_TYPES/4">4</a>
</td>
<td class="col-rowid type-int">4</td>
<td class="col-PARSE_EXCEPTION_ID type-int">3</td>
<td class="col-PARSE_EXCEPTION_DESCRIPTION type-str">UNSUPPORTED_VERSION</td>
</tr>
</tbody>
</table>
</div>
<div id="export" class="advanced-export">
<h3>Advanced export</h3>
<p>JSON shape:
<a href="/corpora-metadata/REF_PARSE_EXCEPTION_TYPES.json">default</a>,
<a href="/corpora-metadata/REF_PARSE_EXCEPTION_TYPES.json?_shape=array">array</a>,
<a href="/corpora-metadata/REF_PARSE_EXCEPTION_TYPES.json?_shape=array&_nl=on">newline-delimited</a>
</p>
<form action="/corpora-metadata/REF_PARSE_EXCEPTION_TYPES.csv" method="get">
<p>
CSV options:
<label>
<input type="checkbox" name="_dl"> download file
</label>
<input type="submit" value="Export CSV">
<input type="hidden" name="_size" value="max">
</p>
</form>
</div> But here's something really weird - the links to the individual rows DO include the <td class="col-Link type-pk">
<a href="/datasette/corpora-metadata/REF_PARSE_EXCEPTION_TYPES/2">2</a>
</td> The navigation bar on that page is correct too: <p class="crumbs">
<a href="/datasette/">home</a> /
<a href="/datasette/corpora-metadata">corpora-metadata</a>
</p> I've also been unable to replicate this in my own local environment, running |
@tballison is there any chance you're running any custom templates in that installation? I'm really confused as to why I can't replicate the bug. |
The sort headers are generated by this template code: datasette/datasette/templates/_table.html Lines 11 to 15 in 5eb8e9b
The export links use this code: datasette/datasette/templates/table.html Line 134 in 5eb8e9b
datasette/datasette/templates/table.html Lines 180 to 201 in 5eb8e9b
|
Here's where datasette/datasette/views/base.py Lines 542 to 545 in 11eb1e0
|
I'm starting this with docker like so:
I'm not doing any templating or anything else custom. Apropos of nothing, I swapped out a simpler db, so this query should now work: |
My headers aren't clickable/sortable with custom sql, but I think that's by design. In the default view, https://corpora.tika.apache.org/datasette/file_profiles/file_profiles, ah, y, now I see that the headers should be sortable, but you're right the base_url is not applied. base_url works with "View and Edit SQL" and with "(advanced)" As you point out, does not work with the export csv, json, other or with the "Next page" navigational button at the bottom. |
@tballison could I see the section of your Apache config that configures the proxying to |
I have a hunch that there may be some extra configuration in play here - could Apache itself be rewriting some of the links using mod_proxy_html? |
I don't think we are, but I'll check with Maruan. I think this is the relevant part of our config?
|
We're using mod_proxy. |
Anything we can do to help debug this? Thank you, again! |
Could you try removing the My hunch is that Normally you would need |
I don't think this fixes it:
And I confirmed that I actually restarted the server. 🤣 |
OK that is really weird. I'll have another go at replicating this locally. |
I found this issue while troubleshooting the same behavior with an nginx reverse proxy. The solution was to make sure I set:
|
@tballison I think that's the solution! It looks like you need to use this in your config:
Instead of this:
Give that a go and let me know if it fixes it. |
@henry501 it looks like you spotted a bug in the documentation - I just addressed that, the fix is now live here: https://docs.datasette.io/en/latest/deploying.html#running-datasette-behind-a-proxy |
+1 Yep! Fixes it. If I navigate to https://corpora.tika.apache.org/datasette, I get a 404 (database not found: datasette), but if I navigate to https://corpora.tika.apache.org/datasette/file_profiles/, everything WORKS! Thank you! |
Fantastic! |
Great, really happy I could help! Reverse proxies get tricky. |
Y, thank you to both of you! |
Originally posted by @tballison in #865 (comment)
The text was updated successfully, but these errors were encountered: