User defined navigation return 404 after press `F5`

NodeBB Development
  • I defined a navigation in admin console named MyView with route /myview
    0_1453360394146_Screenshot from 2016-01-21 15:11:12.png

    Bellowed is the init code in my plugin

    plugin.http = {};
    plugin.http.get = function(req, res, next) {
    	res.render('myview', {});
    plugin.init = function(data, callback) {
    	data.router.get('/api/myview', plugin.http.get);

    code in plugin.json

    "library": "./library.js",
    	"hooks": [
    			"hook": "static:app.load", "method": "init"
    	"staticDirs": {
    		"static": "./static"
    	"less": [
    	"templates": "templates"

    the templates/myview.tpl is quite simple with static HTML 'Hello nodebb'

    Works well when access the page from navigation bar. But the title is missing, it's still 'Home'
    0_1453361080432_Screenshot from 2016-01-21 15:24:19.png

    Stay here, then press 'F5' it becames 404.
    0_1453361207705_Screenshot from 2016-01-21 15:26:39.png

    Any outstanding I should do Or I did it in a wrong way?

  • You have to define a /api/myroute and /myroute so F5 works as well. You can use the helper class from routes.

    Check this out


    var helpers = require.main.require('./src/routes/helpers');
    plugin.init = function(data, callback) {
        helpers.setupPageRoute(data.router, '/myview', data.middleware, [], plugin.http.get);
  • @baris Chrees! This really helps. 👍

Suggested Topics