Express routing problem

I am a novice. I have just come into contact with the node.js and express frameworks. I have configured routing according to the online tutorial, but there are some problems, as follows:

first of all, the file structure is as follows:

clipboard.png

index.js:

 

try to solve it by yourself. If the routes/index.js and routes/about.js files are written into the index.js file (without module export), then the about page can respond normally, but not in different modules.

I have just come into contact with this aspect, and I don"t quite understand what the problem is. I hope I can have some guidance from my predecessors. Thank you.


app.use('/about', userRouter.router)

router.get('/about', (req, res) => {

look at your code. The correct path to about should be http://localhost:3000/about/about

.

you changed it to

in about.js.
router.get('/', (req, res) => {
    res.send('about')
})

try

Menu