~tsileo/microblog.pub-devel

3 3

Oficcially support running in subdir?

Alexey Shpakovsky <alexey@shpakovsky.ru>
Details
Message ID
<d85c74b19edeb0850da88405ebee216e.squirrel@squirrelmail.shpakovsky.ru>
DKIM signature
missing
Download raw message
Hi,

Currently running microblog.pub in a subdir feels a bit hacky. I would
like to make it look more officially supported - but would like to know
what ~tsileo and ~doof think about it first.

I would suggest make it a configuration option in profile.toml file (AFAIK
it is possible to provide root_path as an argument to FastAPI instead of
using a `--root-path` uvicorn flag:
https://fastapi.tiangolo.com/advanced/behind-a-proxy/#setting-the-root_path-in-the-fastapi-app),
and add relevant documentation.

What do you think?
Details
Message ID
<d61b6007-c757-6b8c-811f-f81f8de9efb4@wallace.seattle.wa.us>
In-Reply-To
<d85c74b19edeb0850da88405ebee216e.squirrel@squirrelmail.shpakovsky.ru> (view parent)
DKIM signature
missing
Download raw message
On 2022-11-19 2:42 PM, Alexey Shpakovsky wrote:
> What do you think?

Sounds reasonable to me!  I agree it's a bit hacky to require changes to
the git-tracked supervisord.conf.
Details
Message ID
<fcdd321d-36e5-4d0b-ae2c-db3472dcc789@app.fastmail.com>
In-Reply-To
<d61b6007-c757-6b8c-811f-f81f8de9efb4@wallace.seattle.wa.us> (view parent)
DKIM signature
missing
Download raw message
Now that users in the wild may be running with the current config, we should not break existing instances.

I think we may be able to:

 - parse the "path" from the custom ID if set and expose it as a `BASE_PATH` config item, that would be empty when ran in "normal mode"
 - this would allow us to build relative URLs (for example the recent changes break the CSS when I test on localhost locally, I wanted to so something about it)
- passing the extracted base path to fast API sounds like the right thing to do
- and yes about adding explanation/instructions in the official doc somewhere, we should make it clear that it is for power users and require serving the webfinger document manually (I think serving the nodeinfo, which is also a .well-known could be cool)

I think this will improve the situation without breaking backward compat, but I haven't done extensive digging in the code to see if I missed something.
Alexey Shpakovsky <alexey@shpakovsky.ru>
Details
Message ID
<a165025b50c12cd663076aba9cd2a161.squirrel@squirrelmail.shpakovsky.ru>
In-Reply-To
<fcdd321d-36e5-4d0b-ae2c-db3472dcc789@app.fastmail.com> (view parent)
DKIM signature
missing
Download raw message
Good point about keeping backward compatibility!

On Mon, November 21, 2022 21:40, Thomas Sileo wrote:
>  - parse the "path" from the custom ID if set and expose it as a
> `BASE_PATH` config item, that would be empty when ran in "normal mode"

I actually was thinking about directly opposite: have BASE_PATH setting in
config, set ID based on it, but let users override it:

+BASE_PATH = ''
+if CONFIG.base_path:
+    BASE_PATH = '/' + CONFIG.base_path.strip('/')
+
+ID = f"{_SCHEME}://{DOMAIN}{BASE_PATH}"
+# Let users experiment even further
 if CONFIG.id:
     ID = CONFIG.id

In my testing, it looks backwards-compatible: if I pass root_path='' to
FastAPI() constructor, but execute uvicorn with `--root-path /@alexey`
argument, then it has precedence. I hope it's on purpose and not by
accident?

In other words, with the change above, I can use both "current" way
(setting id in config and root-path in docker-supervisord.conf) and the
"new" way of setting just base_path in config.

I agree that keeping backward compat is nice, but I believe that we can
introduce a user-settable `BASE_PATH` config item without breaking
backward compatibility with currently existing configurations.

Also, I'll try to make a first draft of documentation this coming weekend.
Reply to thread Export thread (mbox)