base_url configuration setting
See original GitHub issueI’ve identified a couple of use-cases for running Datasette in a way that over-rides the default way that internal URLs are generated.
- Running behind a reverse proxy. I tried running Datasette behind a proxy and found that some of the generated internal links incorrectly referenced
http://127.0.0.1:8001/fixtures/...
- when they should have been referencinghttp://my-host.my-domain.com/fixtures/...
- this is a problem both for links within the HTML interface but also for thetoggle_url
keys returned in the JSON as part of the facets datastructure. - I would like it to be possible to host a Datasette instance at e.g.
https://www.mynewspaper.com/interactives/2018/election-results/
- either through careful HTTP proxying or, once Datasette has been ported to ASGI, by mounting a Datasette ASGI instance deep within an existing set of URL routes.
I’m going to add a url_prefix
configuration option. This will default to ""
, which means Datasette will behave as it does at the moment - it will use /
for most URL prefixes in the HTML version, and an absolute URL derived from the incoming Host
header for URLs that are returned as part of the JSON output.
If url_prefix
is set to another value (either a full URL or a path) then this path will be appended to all generated URLs.
Issue Analytics
- State:
- Created 5 years ago
- Comments:27 (17 by maintainers)
Top Results From Across the Web
Configuring the Server Base URL | Confluence Data ...
Go to > General Configuration. · Select Edit. · Enter the new URL in the Server Base URL field. · Save your changes....
Read more >config:baseurl [DokuWiki]
Configuration Setting : baseurl. URL to server including protocol - blank for autodetect. Type: String. Default: The path you should set here ...
Read more >Configuration
This guide is for Cypress 10 and the new JavaScript configuration file format. If you are on an older version of Cypress that...
Read more >How to set proper codeigniter base url?
Base URL should be absolute, including the protocol: $config['base_url'] = "http://somesite.com/somedir/";. If using the URL helper, ...
Read more >Settings.baseURL - Win32 apps
The baseURL property specifies or retrieves the base URL used for relative path resolution with URL script commands that are embedded in ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @wragge,
This looks great, thanks for the share! I refactored it into a self-contained function, binding on a random available TCP port (multi-user context). I am using subprocess API directly since the
%run
magic was leaving defunct process behind 😕Ideally, I’d like some extra magic to notify users when they are leaving the closing the notebook tab and make them terminate the running datasette processes. I’ll be looking for it.
Shipped in 0.39: https://datasette.readthedocs.io/en/latest/changelog.html#v0-39