У меня есть запрос GET для загрузки html-страницы в мой файл rout.js с использованием
app.get('/api/testresult', (req, res) => {
res.sendFile('/path/myfile.html');
});
Кроме того, в моем server.js у меня есть следующее
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const path = require('path');
const port = 8000;
app.use('/', express.static(path.join(__dirname, './app/report')));
require('./app/routes')(app, {});
app.listen(port, () => {
console.log('Server running on ' + port);
});
Однако, когда я пытаюсь сделать GET-вызов, он выдает ошибку на консоли браузера
localhost/:1 Refused to apply style from
'http://localhost:8000/api/testresult/assets/app.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
localhost/:2 GET http://localhost:8000/api/testresult/assets/app.js 404 (Not Found)
localhost/:1 Refused to execute script from 'http://localhost:8000/api/testresult/assets/app.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
Моя файловая структура
MyApp
app
—report
—assets
—app.css
—app.js
—my file.html
—routes
—index.js
—routes.js
node_modules
package.json
server.js
Что мне здесь не хватает?