host multiple pages on nodejs

前端 未结 2 1495
独厮守ぢ
独厮守ぢ 2021-02-06 03:47

So I have my app at http://localhost:8080/

How can I have http://localhost:8080/subpage ? Because it seems like any page that hits :8080 pulls

2条回答
  •  情话喂你
    2021-02-06 04:48

    I hit the same problem as you did, and I think what we were both looking for is basically a routing engine for node.js. Basically, okay fine I get the hello-world example for nodejs, but how do I build something that responds to different requests?

    For future users who land on this page via google, you must look at Express.js and this excellent guide and intro into express, Understanding Express.js. These two will solve the problem

提交回复
热议问题