Skip to content

feat: access other instances#1002

Closed
Gtoasted wants to merge 15 commits into
stoatchat:mainfrom
Gtoasted:token-federation
Closed

feat: access other instances#1002
Gtoasted wants to merge 15 commits into
stoatchat:mainfrom
Gtoasted:token-federation

Conversation

@Gtoasted

@Gtoasted Gtoasted commented Mar 7, 2026

Copy link
Copy Markdown

Building on #997, I am currently implementing token federation. Currently, it is possible to prepend any path with /instance/hostname to instruct the client to access the instance at https://hostname, provided the api is located at https://hostname/api. My plan is to wrap all links in the instance.href function, so that they point to the path with the correct instance prefix. This should provide a basis to implement things like token federation or account switching across instances, as per #999.
As always, feedback would be greatly appreciated.

Gtoasted added 15 commits March 7, 2026 14:09
The purpose of this context is to hold information about a single instance of stoat (information that is currently stored in global configuration)

Signed-off-by: Gtoasted <git@gtoasted.de>
…A_URL

Signed-off-by: Gtoasted <git@gtoasted.de>
…Y_URL

Signed-off-by: Gtoasted <git@gtoasted.de>
…BOX_URL

Signed-off-by: Gtoasted <git@gtoasted.de>
Signed-off-by: Gtoasted <git@gtoasted.de>
…TCHA_SITEKEY

Signed-off-by: Gtoasted <git@gtoasted.de>
Signed-off-by: Gtoasted <git@gtoasted.de>
don't know why the previous commits didn't

Signed-off-by: Gtoasted <git@gtoasted.de>
Signed-off-by: Gtoasted <git@gtoasted.de>
Signed-off-by: Gtoasted <git@gtoasted.de>
@Pecacheu

Pecacheu commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

Tbh I think this could be part of #997 to reduce the PR clutter a little. Good idea for how to handle it tho, but I think /instance/hostname might be a bit long (since it'll be visible in the URL bar shorter is better), how about just /i/hostname. We'd also need to deal with alternative ports somehow, not sure if : is allowed in the URL (it might be, I'd have to double-check)

Also btw I made some changes to Instance.ts in my PR here.
dd73048#diff-af1738d74df827e45ba843a451fd3a25355527b9fd39b7feeeeed22ffa7fef9a

Created an InstanceManager to change Instances, but there are other ways to handle that. If it's part of the URL then it could be handled through the routes in index.tsx and switch via a call to navigate(), but that would require modifying all calls to navigate() throughout the entire app, unless there's some way to set a "base route" that's always prepended

@Gtoasted

Gtoasted commented Mar 7, 2026

Copy link
Copy Markdown
Author

Yeah, I wasn't sure if one monolitihc pr or multiple fine-grained pr's would be better. I'll see if can merge your changes and #997 into this pr later.

You could just urlencode a colon if it comes to that, but I think some other form of configuration discovery (like a well-known uri) would be a better solution either way.

As far as I know, navigate does actually support a base path, but it can only be supplied by the router component, so it would be static and therefore useless. If the url-based approach sticks, it would indeed require modifying all calls to navigate and a, but such is life. Maybe I could make wrapper tags for those, but I'm gonna hold out on such an endeavour until I know that it might actually get merged (or I get bored and do it anyway)).

@Gtoasted

Copy link
Copy Markdown
Author

I don't really have the time to work on this further, and #999 looks promising, so I'll close this now.

@Gtoasted Gtoasted closed this Apr 23, 2026
@Pecacheu

Copy link
Copy Markdown
Contributor

That's fine, your contributions were very helpful in laying the groundwork for the multi instance features

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

Successfully merging this pull request may close these issues.

2 participants