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

Config option for URL prefix #77

Closed
jasewells opened this Issue Jun 26, 2018 · 6 comments

Comments

Projects
None yet
5 participants
@jasewells
Copy link

jasewells commented Jun 26, 2018

I was hoping to run Fathom on an existing domain (same hostname/port), using a URL prefix to proxy requests to the Fathom backend. I can set up something like this in NGINX:

Request for /fathom/blah proxies to -> http://localhost:9000/blah

Fathom gets the request just fine, but then responds with HTML that has references like <link href="/assets/css/styles.css" rel="stylesheet">, which of course doesn’t work since they’re missing my custom /fathom prefix. I would want that example link to instead turn into <link href="/fathom/assets/css/styles.css" rel="stylesheet">.

Is there any chance you might add a configuration option that would make Fathom prefix/prepend an arbitrary subdirectory in front of any CSS/JS/media links in its HTML? Not sure if that is even possible with how Fathom serves the asset files?

@dannyvankooten

This comment has been minimized.

Copy link
Collaborator

dannyvankooten commented Jun 27, 2018

Hey @jasewells,

I can see how this would simplify managing certs etc. somewhat, so I'm definitely going to look into this.

It should be possible with how Fathom is serving its asset files, but does require knowledge of the "path to strip off" in order to determine which file is being requested. Nothing a configuration value can't fix however. 😸

@zvitez

This comment has been minimized.

Copy link

zvitez commented Sep 21, 2018

Hey!

Any progress on this? Have the same request :)

@dannyvankooten

This comment has been minimized.

Copy link
Collaborator

dannyvankooten commented Nov 2, 2018

Hey, sorry for the delay on this.

After 9589072, you should now be able to use Fathom from subdirectories. You may have to add a rewrite rule to your server configuration, eg using NGINX:

location /fathom/ {
    rewrite ^/fathom(/.*)$ $1 break;
    proxy_pass  http://127.0.0.1:8080/;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
@zvitez

This comment has been minimized.

Copy link

zvitez commented Nov 2, 2018

Hey, thanks Danny! I'll try it as soon as it's released

@JacobEvelyn

This comment has been minimized.

Copy link

JacobEvelyn commented Nov 28, 2018

@dannyvankooten I may be doing something wrong, but when I try the Nginx config above, I get requests to mysite.com/fathom/... correctly proxied to the fathom server, but the assets are still requested at mysite.com/assets/... instead of mysite.com/fathom/assets.... Looking at the commit you linked, this seems expected, as I believe relative URLs for DOM resources are typically relative to the domain unless there's a base element defined.

In the meantime, I'm using a custom subdomain for my Fathom instance, which isn't ideal but works.

@xPaw

This comment has been minimized.

Copy link

xPaw commented Dec 14, 2018

This issue isn't entirely fixed, as the API requests are still executed against the root folder like /api/session.

ericand added a commit to ericand/fathom that referenced this issue Dec 15, 2018

dannyvankooten added a commit that referenced this issue Dec 17, 2018

Merge pull request #195 from ericand/relative_url
relative url for api/session calls #77
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.