bumi / lnme

Your friendly Bitcoin Lightning ⚡ payment page ⚡
MIT License
165 stars 31 forks source link

How to serve internal site on non-default root path? #55

Open neocogent opened 1 year ago

neocogent commented 1 year ago

I'm trying to serve lnme with nginx as reverse proxy. I've set it so that a path url like

test.home.kg/pmt/

gets passed to back end at localhost:1323 (the default).

This proxy works but only when as root of the domain. If I add in the /pmt prefix then the internal site isn't served. Instead it serves a <pre></pre> block with links to referenced files, eg. js, css, svg on page.

I can get around this by using a new port and having it serve as root. And I gather I could copy the internal default files and put them in a server path and use that as "external" site.

But I'm trying to see if there is a shortcut or setting that allows serving the embedded site on a non-root path? This allows a wee bit simpler integration of page into a cluster of other pages on my site.

edit: I wanted to add... by editing the nginx proxy_pass directive to have a trailing slash I could get the main page to serve but when a test "send" is done it does not complete. It seems to be the invoice is directed to a /v1/ prefix and that is not handled well when not at root. eg. this is my relevant nginx conf:

location /pmt/ { proxy_pass http://127.0.0.1:1323/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }

bumi commented 1 year ago

ah I see. good point. I think we should use relative paths in the app or make the root domain/path configurable.

we could probably try to add the path here: https://github.com/bumi/lnme/blob/master/files/assets/lnme.js#L58

or dynamically add a data-lnmeBaseUrl ="https://example.com/full/path/" here: https://github.com/bumi/lnme/blob/master/files/root/index.html#L154

do you want to try this?