Proxy the path under NodeBB root to another one.
-
http://example.com is my nodebb site URL. I configured a proxy to pass http://example.com/app to my other Python server. But when clicking http://example.com/app in a post of NodeBB, then a page opens, which says the URL not found. Refreshing it again opens the real page http://example.com/app (my Python app).
I use Apache proxy server. I hope my Python app opens by the first click on the link.How can I fix this?
-
Ah, that's a tricky one, since it's a non-traditional way of setting up services to work together. NodeBB considers all subfolders part of its purview, which is why ajaxify is kicking in (but returning 404 since that route doesn't exist).
There's this bit of code in
ajaxify.js
, which you'll need to update on your install, to include/app
: https://github.com/NodeBB/NodeBB/blob/9f78bd7a121392d7102ff63cd78591000294e22c/public/src/ajaxify.js#L400-L404 -
There's another option which is to listen on
action:ajaxify.start
and setpayload.url = null
if it matches/app
-
@hotteshen glad you solved it! Do you mind sharing your solution for the benefit of others having a similar issue in the future?
-
I modified html link on my custom home page.
from<a href="/app/">App</a>
to
<a href="javascript:window.location.href=window.location.href + 'app/'">App</a>
- Pros: no change to NodeBB source, so that I can update NodeBB as new release comes.
- Cons: The link URL is ugly and can not be copied for quote.
Ref: Difference between window.location.href=window.location.href and window.location.reload()