Skip to content

Conversation

@tilusnet
Copy link
Contributor

My self hosted apps are typically under a https://mydomain.com/app path.
The web app should have a way of handling requests under a base path which is not necessarily root.

This is my first attempt.

I believe some more code tweaking is needed since not all requests seem to go through the python server's handler.

Inputs and suggestions are highly appreciated as I'd like to be able to host a variant of this app with configurability on reverse proxies.

Thanks!

@mreichhoff
Copy link
Owner

for this one:

not all requests seem to go through the python server's handler

I think there are a few things to look at:

  • the frontend is explicit in its setting of the path via history.pushState. The code is: const newUrl = `/${activeGraph.prefix}/${words}`;, so we might need a global base_path variable on the frontend as well, so that we could set newUrl to ${basePath}/${activeGraph.prefix}/${words}. I could help with this if needed, and then presumably it could be overridden in the same way we'd override USE_FIREBASE (let me know if that doesn't make sense and I can dig into it a bit more)
    • related: back when I hosted HanziGraph on github pages, I recall I changed most of the paths in the JS to be ./ instead of /, since the paths would've been mreichhoff.github.io/HanziGraph/whatever.
    • The service worker might also have to change to include the base path, as it also has a list of files to cache. Same with data-load.js.
  • history.pushState changes the path in the browser's URL bar, but it doesn't trigger a separate request to the server, so perhaps that's part of the discrepancy you're noticing? Or feel free to let me know which files you weren't seeing requested for help debugging!

@tilusnet
Copy link
Contributor Author

Yes I only remember that after "cold booting" the server, subsequent (and repeated) requests were no longer hitting the server as often, likely due to browser caching?
I can fire up that debug server again and give you some examples if it helps.

@tilusnet
Copy link
Contributor Author

So it seems there is a bit of work needed on the core code to fully support base_path am I right?
Thanks for considering looking into this.

For the time being I opened an extra port for this app on my server - long term however I'd like it more secure behind a reverse proxy (+certificates), the base path will become very handy especially with Docker in the mix.

@mreichhoff
Copy link
Owner

So it seems there is a bit of work needed on the core code to fully support base_path am I right?

yes, that's correct, though I have this possibly silly idea that we could just run some string replacements with sed in your docker setup. I would just need a common pattern for the paths in the JS files

@tilusnet
Copy link
Contributor Author

Cool, quick wins are good.

@tilusnet
Copy link
Contributor Author

Hey hey.

I'm realising there's one more reason to support reverse proxy: HanziGraph doesn't allow saving the dictionary offline and enabling the tool offline, unless the connection is over https (unless I'm wrong?). The reverse proxy would enable the certificates for https.

@mreichhoff
Copy link
Owner

nah, you're right: service workers are https-only, and I lean on those for offline support.

Did you want to try writing in some sed in the dockerfile in this PR, or you want me to give it a shot?

@tilusnet
Copy link
Contributor Author

If you can please give it a shot, as I wouldn't know what I am doing :)

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