Quando vinculo o arquivo javascript em html, ele envia uma solicitação ao servidor e causa o erro
Estou usando express e node.js no mecanismo de modelagem de back-end e ejs no front-end. Meu app.js fica assim
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);
});
});
rquivo @ 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>
Mas quando eu direciono a página para book / 1234, tenho o seguinte logon no meu servidor
this book : 1234
this book : jquery-3.3.1.min.js
this book : book.js
Por que jquery-3.3.1.min.js e book.js são enviados para a rota book /: id? Estou enviando apenas book / 1234, mas jquery-3.3.1.min.js e book.js também são enviados ao servidor e estão causando erro.
O registro do console do navegador é este
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.