fazaa
November 13, 2023, 5:48am
1
Tell us what’s happening:
I can’t pass the stage. When I enter my project on ‘Solution Link’ it says helmet.hidePoweredBy() middleware should be mounted correctly
But, on webview it shows no error. This is my code,
const helmet = require(‘helmet’);
const express = require(‘express’);
const app = express();
app.use(helmet.hidePoweredBy());
app.get(‘/’,(req, res) => {
res.send(‘Hello, World’);
});
app.listen(3000);
I think I coding it right, maybe. Please help me fix this. Thank you!
Your project link(s)
https://boilerplate-infosec--fazaotaku.repl.co/
solution:
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/118.0
Challenge Information:
Information Security with HelmetJS - Hide Potentially Dangerous Information Using helmet.hidePoweredBy()
1 Like
zaklina
November 14, 2023, 3:54pm
2
2 Likes
The myApp.js file has had modifications which are causing your repl to fail the tests.
This code has been added, which shouldn’t be there:
app.get('/',(req, res) => {
res.send('Hello, World');
});
app.listen(3000);
This code has been removed from the bottom of the file:
module.exports = app;
const api = require('./server.js');
app.use(express.static('public'));
app.disable('strict-transport-security');
app.use('/_api', api);
app.get("/", function (request, response) {
response.sendFile(__dirname + '/views/index.html');
});
let port = process.env.PORT || 3000;
app.listen(port, () => {
console.log(`Your app is listening on port ${port}`);
});
Remove the first code block and replace it with the second and your repl should pass.
1 Like
fazaa
November 17, 2023, 6:41am
4
so, the code list like this?
const express = require(‘express’);
const helmet = require(‘helmet’);
const app = express();
app.use(helmet.hidePoweredBy());
I try this before following the hint but still error.
That code is correct but you are missing a whole code block which should be at the bottom of the myApp.js file, as I said in my previous post. That code block is part of the starter code for this project and shouldn’t have been removed.
1 Like
system
Closed
May 17, 2024, 11:48pm
6
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.