How to use live-server with parameter routes

41 views Asked by At

I would like to be able to access parameter routes using live-server but it is unclear to me how to make the cli call to get it to work... or if it even can work.

Currently I have tried running my node server.js

node server.js

then run

live-server public/ 

which shows my index.html file but trying http://127.0.0.1:3000/user/1 this parameter route doesn't work. and

live-server --host=http://127.0.0.1:3000 

but this doesn't work at all.

any help would be great thank you.

here is an example server server.js

    var express = require('express');
    var app = express();
      
    app.get('/user/:id', function(request, response){
       var id = request.params.id;
       response.send("User id is " + id);
    });
      
    app.listen(3000, () => console.log(`App listening on port 3000`))
0

There are 0 answers