Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Using a Reverse Proxy fails to load - Not handling a "prefix" path. #561

Open
fisherthewol opened this issue Jan 12, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@fisherthewol
Copy link

Description of the Bug

Not sure if this is a bug or more a feature request (which I'm happy to write a PR for) - When using a reverse proxy with a "prefix" in the path, the app fails to load - it get's stuck on the Loading page. Looking at the console it seems like it assumes no prefix and therefore gets a 404 when trying to load /assets/index-673c0d5b.js

Expected Behavior

App should load.

To Reproduce

Steps to reproduce the behavior:

  1. Run the app on a machine. It is then accessible at localhost:10801
  2. Reverse proxy (I'm using caddy) a route to that port:
handle_path /fishfiles* {
    reverse_proxy localhost:8080
}
  1. Try to access the app at mydomain/fishfiles (or mydomain/fishfiles/).
  2. Gets stuck on the loading page, app is inaccessible.

Screenshots

Screenshot From 2025-01-12 04-18-58
Screenshot From 2025-01-12 04-19-23

Debugging Information

Using the stock config file.

Environment:

  • OS: Fedora 41
  • Browser: Firefox 134.0

Build Details:

  • Version: 0.0.9
  • Docker: no, single-executable. Currently running in the commandline but expect to run it inside of a Systemd unit.

Additional context
I've found #536 but I think that's a more specific case, with authentication. I've also found someone who seems to have it working with a reverse proxy already? #197 But they've got no details on that in the issue itself.

@fisherthewol fisherthewol added the bug Something isn't working label Jan 12, 2025
@aaronleopold
Copy link
Collaborator

aaronleopold commented Jan 12, 2025

Not sure if this is a bug or more a feature request (which I'm happy to write a PR for)

To be honest, I'm not 100% sure which it might be either. If you do wind up putting up a PR, it would be much appreciated!

Otherwise, I'll try to find some time over the next week or so to at least reproduce on my end. I use Caddy for reverse proxies throughout my home server setup, but always subdomains and not domain paths/prefixes.

@aaronleopold
Copy link
Collaborator

aaronleopold commented Jan 12, 2025

I messed around a little this morning, I pushed a commit that is worth discussing: dc1dda9

It "fixes" the issue, but not in a way that can actually be committed to the repo, I just hard coded a few things to get it mostly working with your setup. In particular:

  • DOMAIN_SUB_PATH is fixed, it would have to be picked up dynamically somehow. Maybe injecting something into window
  • I've added a basename to the router root, same issue and likely same fix described above
  • The base field in the vite config was set to /web/. From what I can tell this seems to be a requirement, but is a build-time config which means it won't work for us. I tried a few guesses like ./ to try to get some kind of dynamic base supported but nothing stuck. I can't make sense of how we could leverage this, but it might be the way forward

To repro this yourself, you'll need to be able to at least build the webapp. You can use the latest server binary and set a custom client directory do your local build:

yarn web build
caddy run

@fisherthewol
Copy link
Author

Sorry, not had chance to boot up my PC yet. Will take a stab when I do.

I've not got any vite knowledge but coming from the C# world, my instinct here is to reach for templating. Not sure if that's something already in the repo? But as you say, currently a build-time constant, so maybe not appropriate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants