GithubHelp home page GithubHelp logo

Comments (3)

analog-nico avatar analog-nico commented on July 22, 2024

Hi @pitup3 I took your code and commented out some lines. This code is working:

var express = require('express'),
    //routes = require('./routes'),
    //user = require('./routes/user'),
    http = require('http'),
    //metafetch = require('metafetch'),
    //expressValidator = require('express-validator'),
    path = require('path');
//var moment = require('moment');
var bodyParser = require('body-parser');
var hpp = require('hpp');
//var errTo = require('errto');
//var Err = require('custom-err');

var app = express();
var server = http.createServer(app);
//all environments
app.set('port', process.env.port || 3001);
//app.set('views', __dirname + '/views');
//app.set('view engine', 'jade');
//app.use(express.favicon());
//app.use(express.logger('dev'));
//app.use(express.bodyParser());

//app.use(expressValidator()); // this line must be immediately after express.bodyParser()!

//app.use(express.methodOverride());
//app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));

app.use(bodyParser.urlencoded({extended: true}));
app.use(hpp()); // <- THIS IS THE NEW LINE

app.get('/hpp',function(req,res)
{
    console.log("req.query.fname : ",req.query.fname);
    console.log("req.query.lname : ",req.query.lname);
    console.log("req.query : ",req.query);
//console.log("req.body : ",req.body);
//res.send(req.query);
});

http.createServer(app).listen(app.get('port'), function(){
    console.log('Express server listening on port ' + app.get('port'));
});

Since you are still using express.favicon() and other deprecated middlewares I wonder if you are just using an express version that is too old.

Anyway, if you get the above version working as well you can start commenting in all lines one by one. Maybe some middleware I commented out is actually producing side effects.

Please let me know what you find out.

from hpp.

pitambar avatar pitambar commented on July 22, 2024

yes itz working now, thnx buddy, i have to update my middleware now

from hpp.

analog-nico avatar analog-nico commented on July 22, 2024

You are welcome.

from hpp.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.