When I call http://localhost:5000/surveycreate/4, it successfully redirects me to the surveypage.html page.
However, calling http://localhost:5000/surveycreate does not work as expected. Instead of redirecting me, it leads me back to my main index.js file in the public folder without even displaying "regular get".
I'm puzzled why this is occurring?
The surveypage.js route includes:
const path = require("path");
const router = express.Router();
router.use(express.static(path.join(__dirname, "../public")));
router.get('/:id', async (req, res) => {
console.log("get with id");
res.sendFile(path.join(__dirname, "../public/Surveypage.html"));
})
router.get('/', async (req, res) => {
console.log("regular get");
res.sendFile(path.join(__dirname, "../public/Surveypage.html"));
})
module.exports = router;