Reputation: 917
I'm using express for serving static folder using loopback 4 like
let dir = path.join(directory)
server.use(express.static(dir));
server.listen(3001);
But my application is running on the 4200 port and server.listen(3001) creates A new port but i want to do the same on 4200 If i'm giving server.listen(4200) then that not start because its can't run on two server on same port
Is that possible to serve file on existing port
Upvotes: 1
Views: 595
Reputation: 3926
You can add
app.use('/static', express.static('public'));
to your app main file.
This serves your files in the public
folder in the /static
endpoint, so if you have a file public/hello.jpg
you can use it from localhost:4200/static/hello.jpg
.
Upvotes: 1