Hello! I set up a custom route via own plugin:
plugin.init = async function (params, callback) {
var router = params.router;
var middleware = params.middleware;
// Define the function that renders the custom route.
function render(req, res, next) {
// Get whatever data you want to send to the template here.
let data = {};
// This is the path to your template without the .tpl, relative to the templates directory in plugin.json
var template = 'testinger'
// GET the requested URL
var requestedURL = req.originalUrl;
if(!req.uid){
// ITS A GUEST
data.debug = "Guest";
data.reqedURL = requestedURL;
req.session.returnTo = requestedURL;
return res.redirect('/login');
//
}else{
// ITS A REGISTERED
data.debug = "LOGGED IN!";
data.reqedURL = requestedURL;
// Send the page to the user.
res.render(template, data);
}
}
// This actually creates the routes, you need two routes for every page.
// The first parameter is the actual path to your page.
params.router.get('/discord/topic', params.middleware.buildHeader, render);
};
It works when I access the url directly.

But if I use a forum internal link to get to the page it drops an error:

Also logout
button isn't working in both situations.
client console prints following:

Server console log is ok and there are no errors.
What do i wrong?
€:
But if I use a forum internal link to get to the page it drops an error:
This is fixed by define /api/ route too:
params.router.get('/api/discord/topic', render);
And Logout-Button is still not working...
but only in my custom route... everything is working fine elsewhere
Logout-Button fixed
I now use:
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`);
setImmediate(next);
}], (req, res) => {
winston.info(`[plugins/discord-topic] Navigated to ${nconf.get('relative_path')}/discord-topic`);
render(req, res); // replace this with res.render('templateName');
});
instead of:
params.router.get('/discord/topic', params.middleware.buildHeader, render);
But why is it looking for a source I didn't defined?
Failed to load resource: the server responded with a status of 404 ()
GET https://nodebb.development.fail/assets/src/client/testinger.js?v=9ono28m56s4 net::ERR_ABORTED 404
Everything seems to be working but why is this last error appearing?