Skip to content

Allow userscripts to work in subpath.#6

Open
ChilledSlim wants to merge 1 commit into7dJx1qP:masterfrom
ChilledSlim:master
Open

Allow userscripts to work in subpath.#6
ChilledSlim wants to merge 1 commit into7dJx1qP:masterfrom
ChilledSlim:master

Conversation

@ChilledSlim
Copy link

@ChilledSlim ChilledSlim commented Mar 31, 2023

Within StashUserscriptLibrary.js, /graphql is hardcoded which prevents it from working in a subpath (ie: if a reverse proxy points to https://mydomain:1234/stash/ or https://mydomain:4321/apps/stash/). This causes calls to the graphql interface to throw a 404 error.

It should use the current base path as a part of that. I have tested this both by accessing via IP address (ie: http://192.168.x.x:9999/) , in a root path (https://stashapp.mydomain.com:9999), in a subpath (https://apps.mydomain.com:9999/stash/ ).

document.querySelector("head > base").href appears to work in all cases and returns correctly. This is because stash sets <base href="/stash/"> or <base href="/"> as per its configuration. Note that if that behaviour ever changes in stash, this code would need to be updated. Currently, it expands to the correct path to graphql.

@ChilledSlim
Copy link
Author

ChilledSlim commented Mar 31, 2023

Sorry- this doesn't work correctly in all circumstances at this point due to the regex matching on location.href and location.origin.

Will review further in the near future and try and get it all to work nicely. Shelf this for now.

We need to include baseURL = document.querySelector("head > base").getAttribute('href') and incorporate that baseName variable in the various tests [which will be / if there is none set] -OR- simply use document.querySelector("head > base").href (which is expanded by the browser) instead of all the other logic to find the basename and test paths.

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.

1 participant