Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
I'm in the middle of writing a NodeBB plugin. Is there anything immediately available within the client side JS that will allow me to get the base URL for ajax calls or should I simply take it from the window object?
Thanks
@CCob config.relative_path
config.relative_path
@PitaJ said in Best way to get base URL from client side JS:
So would I simply take location.origin + config.relative_path as the root to the NodeBB install?
@CCob yep pretty much.
@PitaJ, is there a simple way to find the client IP, similar to config.relative_path?
G
i need get the fields of an authorized user
M
ahh nice! Thanks @PitaJ I could not find any info on the docs: https://docs.nodebb.org/en/latest/plugins/create.html
will give it a try.
I
Thanks @jarey , I was using shiny new fetch api but wasn't including credentials. silly me.
J
@lewismcmahon There's no way to know what the full url is besides what's presented in config.json, since multiple URLs can point to the same NodeBB.
The nconf solution is the easiest.
Inside of the client script... Anyway, I just restarted NodeBB and tried it again, it works fine now 🙂 Thank you!