Skip to content
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

Get this working with the new Datasette base_url feature #1

Closed
simonw opened this issue Mar 24, 2020 · 8 comments
Closed

Get this working with the new Datasette base_url feature #1

simonw opened this issue Mar 24, 2020 · 8 comments

Comments

@simonw
Copy link
Owner

simonw commented Mar 24, 2020

I've been building a base_url config feature in simonw/datasette#394 - let's see if I can get it working here.

@simonw
Copy link
Owner Author

simonw commented Mar 24, 2020

I installed datasette-debug-asgi in 12c7869 - here's the output: https://hub.gke.mybinder.org/user/simonw-jupyters--datasette-demo-t01stn1g/datasette/-/asgi-scope

{'client': ('10.12.3.15', 0),
 'headers': [(b'cookie',
              b'username-hub-gke-mybinder-org="2|1:0|10:1585093877|29:userna'
              b'me-hub-gke-mybinder-org|44:ODg0ZGViMDBjYWVmNGEzOWIxZmYxNDdjM'
              b'zU2YjZlMTk=|75dde2c6083c112a082f349faad188dd626f9708c54ab51c'
              b'c61cf5411bdad069"; _xsrf=2|66feed18|b5b48b7e7b635b4ad024890d'
              b'afb0f189|1585093877'),
             (b'upgrade-insecure-requests', b'1'),
             (b'dnt', b'1'),
             (b'accept-encoding', b'gzip'),
             (b'accept-language', b'en-US,en;q=0.5'),
             (b'accept',
              b'text/html,application/xhtml+xml,application/xml;q=0.9,image/'
              b'webp,*/*;q=0.8'),
             (b'user-agent',
              b'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:74.0) Gecko'
              b'/20100101 Firefox/74.0'),
             (b'x-scheme', b'https'),
             (b'x-original-uri',
              b'/user/simonw-jupyters--datasette-demo-t01stn1g/datasette/-/a'
              b'sgi-scope'),
             (b'x-forwarded-proto', b'https,http'),
             (b'x-forwarded-port', b'443,80'),
             (b'x-forwarded-host', b'hub.gke.mybinder.org'),
             (b'x-forwarded-for', b'148.64.98.14,10.12.3.15'),
             (b'x-real-ip', b'148.64.98.14'),
             (b'connection', b'close'),
             (b'host', b'hub.gke.mybinder.org'),
             (b'x-forwarded-context',
              b'/user/simonw-jupyters--datasette-demo-t01stn1g/datasette'),
             (b'x-proxycontextpath',
              b'/user/simonw-jupyters--datasette-demo-t01stn1g/datasette')],
 'http_version': '1.1',
 'method': 'GET',
 'path': '/-/asgi-scope',
 'query_string': b'',
 'raw_path': b'/-/asgi-scope',
 'root_path': '',
 'scheme': 'https,http',
 'server': ('127.0.0.1', 38637),
 'type': 'http'}

@simonw
Copy link
Owner Author

simonw commented Mar 24, 2020

Interesting - it looks like the Binder proxy sends /-/asgi-scope as the incoming URL path, not /user/simonw-jupyters--datasette-demo-t01stn1g/datasette/-/asgi-scope - but the original path IS available in the x-proxycontextpath header.

@simonw
Copy link
Owner Author

simonw commented Mar 24, 2020

https://jupyter-server-proxy.readthedocs.io/en/latest/ looks like the relevant documentation.

@simonw
Copy link
Owner Author

simonw commented Mar 24, 2020

Docs here https://jupyter-server-proxy.readthedocs.io/en/latest/server-process.html say:

absolute_url: True if the URL as seen by the proxied application should be the full URL sent by the user. False if the URL as seen by the proxied application should see the URL after the parts specific to jupyter-server-proxy have been stripped.

So I think I want that set to True.

simonw added a commit that referenced this issue Mar 25, 2020
Also formatted using Black. Refs #1.
@simonw
Copy link
Owner Author

simonw commented Mar 25, 2020

That resulted in an infinite loop. I'll try absolute_url: False.

simonw added a commit that referenced this issue Mar 25, 2020
@simonw
Copy link
Owner Author

simonw commented Mar 25, 2020

https://hub.gke.mybinder.org/user/simonw-jupyters--datasette-demo-8s26ppik/datasette/-/config confirms that base_url is set:

    "base_url": "/user/simonw-jupyters--datasette-demo-8s26ppik/"

@simonw
Copy link
Owner Author

simonw commented Mar 25, 2020

Aha!

<!DOCTYPE html>
<html>
<head>
    <title>Datasette: dakar_sql</title>
    <link rel="stylesheet" href="/user/simonw-jupyters--datasette-demo-8s26ppik/-/static/app.css?ffa51a">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">



</head>
<body class="index">

<nav class="hd"></nav>

<div class="bd">

<h1>Datasette</h1>





    <h2 style="padding-left: 10px; border-left: 10px solid #3ce9d5"><a href="/user/simonw-jupyters--datasette-demo-8s26ppik/dakar_sql">dakar_sql</a></h2>
    <p>
        24,942 rows in 7 tables
    </p>
    <p><a href="/user/simonw-jupyters--datasette-demo-8s26ppik/dakar_sql/waypoints" title="16265 rows">waypoints</a>, <a href="/user/simonw-jupyters--datasette-demo-8s26ppik/dakar_sql/ranking" title="4579 rows">ranking</a>, <a href="/user/simonw-jupyters--datasette-demo-8s26ppik/dakar_sql/stagemeta" title="2642 rows">stagemeta</a>, <a href="/user/simonw-jupyters--datasette-demo-8s26ppik/dakar_sql/crew" title="543 rows">crew</a>, <a href="/user/simonw-jupyters--datasette-demo-8s26ppik/dakar_sql/teams" title="334 rows">teams</a>, <a href="/user/simonw-jupyters--datasette-demo-8s26ppik/dakar_sql">...</a></p>



</div>

<div class="ft">Powered by <a href="https://github.com/simonw/datasette" title="Datasette vrefs/pull/708/head">Datasette</a>

</div>




</body>
</html>

Those URLs are almost correct, but they should have /datasette/ on the end of them.

@simonw
Copy link
Owner Author

simonw commented Mar 25, 2020

Woohoo! That seems to work: https://hub.gke.mybinder.org/user/simonw-jupyters--datasette-demo-fc7aqzrf/datasette/dakar_sql/waypoints

Cursor_and_dakar_sql__waypoints__16_265_rows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant