Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Is there any specific order of app.router , express.urlencoded and express.static(__public + "/public");

Is there any specific order of app.router , express.urlencoded and express.static(__public + "/public");

Problem

Is there any Specific order in which these three commands should be written in the app.configure function?

app.use(express.urlencoded());
app.use(app.router);
app.use(express.static(__dirname + '/public'));

I am asking this because when I change their order , I sometimes get an ENOENT error or some middleware doesn't work.

Problem courtesy of: Raman Singh

Solution

So in the default app.js file express creates the order is

app.use(express.bodyParser()); // or app.use(express.urlencoded())
app.use(app.router);
app.use(express.static(__dirname + "/public"));

So I guess this is the right way...

Solution courtesy of: Raman Singh

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Is there any specific order of app.router , express.urlencoded and express.static(__public + "/public");

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×