• I want to add my own custom route that can take POST requests and write my own logic to provide a dynamic response.

    I tried nodebb-plugin-custom-pages, but seems like that only does a GET request and only way to add content there is by ACP->/extend/widgets.

    Im not advanced enough to write my own plug ins , is there a simpler way to achieve what I need?

  • GNU/Linux Admin

    @ape nope, unfortunately not. You'll have to create a plugin and attach a listener to static:api.routes.

    Check out the quickstart plugin, it has example logic for this hook.

  • @julian Thanks for the reference.

    I loaded the Quickstart plugin and followed the example.
    Added my route but I’m still getting “not found” when I go to http://localhost:4567/test321.

    plugin.addRoutes = async ({ router, middleware, helpers }) => {
    	function render(req, res, next) {
    	  helpers.formatApiResponse(200, res);
    	  //  res.send('Test') // tried this also
    	router.get('/test321', render);
    	router.get('/quickstart/:param1', middleware.authenticate, (req, res) => {
    		helpers.formatApiResponse(200, res, {
    			foobar: req.params.param1,

  • @ape Take a look at my yesterday's topic.

    Had similar problems, maybe the topic helps you.


    routeHelpers.setupPageRoute(router, '/discord/topic/', middleware, [(req, res, next) => {
    		winston.info(`[plugins/discord-topic] In middleware. This argument can be either a single middleware or an array of middlewares`);
    	}], (req, res) => {
    		winston.info(`[plugins/discord-topic] Navigated to ${nconf.get('relative_path')}/discord-topic`);
    		render(req, res);	// replace this with res.render('templateName');
  • GNU/Linux Admin

    @ape if you're using that hook, the routes are mounted to /api/v3, so the definition you provided would end up being accessible at /api/v3/test123

Suggested Topics

| | | |