0

I created below sample server.js and in this I want server to load default index.html at http:localhost:3000/public but it is loading route "/products/?query" at above path, please let me know where i am wrong in implementing.

 var restify = require("restify");
 var server = restify.createServer();

 server.use(restify.acceptParser(server.acceptable));
 server.use(restify.queryParser());
 server.use(restify.bodyParser());
 server.pre(restify.pre.sanitizePath()); 

 server.get("/products/?query",function(req,res,next){

 res.send("product listing based on query");
 return next();
 })


 server.get(/\/public\/?.*/, restify.serveStatic({
directory: './docs',
 default: 'index.html'
 }));

 server.listen(3000,function(){
console.log("server is listening at 3000 port");
 })

I want index.html spa page to load and in controller I will call $http.get("/products/?query",param) to get product details.

Philip Kirkbride
  • 21,381
  • 38
  • 125
  • 225
user3231742
  • 77
  • 1
  • 2
  • 10
  • Documentation says, that handlers run in order they've been registered. Try to change order public and product routes. – vanadium23 Apr 21 '15 at 19:13
  • Thanks vanadium23, it helped. I clicked on up vote two times, now it is not allowing me to do same for your answer. it is saying you have undone so I can't up vote again. – user3231742 Apr 22 '15 at 06:45

0 Answers0