feat: support hosting sofie under subdirectory #1405
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
About the Contributor
This pull request is posted on behalf of the BBC
Type of Contribution
This is a: Feature
New Behavior
This allows sofie to be hosted under a subdirectory instead of at the root of a domain.
It is controlled by the meteor ROOT_URL environment variable, should be set to something like
http://my-domain/sofie/
.Going forward this will require some care from devs to not break, which should be limited to needing to ensure that the correct subpath prefix is used whenever generating urls or absolute paths.
To allow this to work purely runtime, when meteor serves the webui it is performing some path mangling to provide the correct paths. Vite is also setup to host in development in a similar way, for easier development testing.
As part of this, I have changed how the meteor config gets fed to the client. The webui is now reliant on loading the config before it can start to do other things or the paths will be wrong, making the previous approach of including a file hazardous. (This gave some frustration during dev, as if the config didnt load in time, react-router would decide that the subpath the page was loaded over to be 'wrong' and redirect to the root of the domain, causing subsequent page loads and some assets to fail).
As we already need to mangle the html file to update the paths, we now inject the config into the file instead.
During development it still loads as its own file, because the html does not touch meteor.
Testing
I have tested this in dev with and without a subdir, both direct and behind nginx.
And in docker both with and without a subdir.
Affected areas
Time Frame
Other Information
Status