My Node/Express server was functioning correctly with the route "/:world", and the CSS file could be found without any issues.
However, upon changing the route to "/:world/:page", the server no longer locates the CSS file as expected.
I'm relatively new to this, so I'm wondering why this simple change is causing an issue. Any suggestions on how to solve this?
const express = require('express');
const bodyParser = require('body-parser');
const path = require('path');
const request = require('request-promise');
const port = process.env.PORT || 3000;
const app = express();
app.use(bodyParser.json());
app.use(express.static(__dirname + '/views'));
app.set('view engine', 'ejs');
app.get('/:world/:page', async (req, res) => {
const world = req.params.world;
const page = req.params.page;
const worldInfo = await getWorldInfo(world);
if (!worldInfo.world.world_information.players_online) {
res.render('error.ejs');
} else {
const playersList = await getPlayersList(worldInfo, page);
res.render('index.ejs', {
playersList: playersList,
world: world
});
}
});
app.listen(port, () => {
console.log('Server is running on port ' + port);
});