а также

ользую Express и Node.js в бэкэнд и EJS шаблонизатор в интерфейсной части. Мой app.js выглядит так

app.get('/book/:id', (req, res)=>{
var book_id = req.params.id;
console.log('this book :', book_id);
Book.findOne({
    book_id
}).then((book)=>{
    res.render('book.ejs', {book, title: "Book"});
}).catch((e)=>{
    // console.log(e);
});
});

файл book.ejs

<!DOCTYPE html>
<html>
<head>
    <title><%= title %></title>
    <script type="text/javascript" src="jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="books.js"></script>
</head>
<body style="font-family: arial">
    <h1><%= title %></h1>
</body>
</html>

Но когда я направляю страницу к книге / 1234, я получаю следующий логин на моем сервере

this book : 1234
this book : jquery-3.3.1.min.js
this book : book.js

Почему jquery-3.3.1.min.js и book.js отправляются в маршрут book /: id? Я только отправляю book / 1234, но jquery-3.3.1.min.js и book.js также отправляются на сервер и вызывают ошибку.

Журнал консоли браузера это

GET http://localhost:3000/book/jquery-3.3.1.min.js net::ERR_ABORTED 500 (Internal Server Error)
1234:1 Refused to execute script from 'http://localhost:3000/book/jquery-3.3.1.min.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
1234:6 GET http://localhost:3000/book/books.js net::ERR_ABORTED 500 (Internal Server Error)
1234:1 Refused to execute script from 'http://localhost:3000/book/books.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

Ответы на вопрос(3)

Ваш ответ на вопрос