The answer is simple, how can I serve - static with a route?

I want to do something like

// server.js app.use('/client', loopback.static(__dirname + '/../client')) 

using middleware.json , but the example only works with the root

 "files": { "loopback#static": { "params": "$!../client" } }, 
+7
source share
3 answers

You should use the paths property, i.e.

 "files": { "loopback#static": { "paths": "/client", "params": "$!../client" } }, 

Details here .

+6
source

I created a new boot / routes.js file

 var path = require("path"); module.exports = function(app) { app.get('/ping', function(req, res) { res.sendFile(pt('client/index.html')); }); }; function pt(relative) { return path.resolve(__dirname, '../..', relative); } 
+2
source

Have you tried

 "files": { "loopback#static": { "params": "$!../../client" } } 
0
source

Source: https://habr.com/ru/post/982786/


All Articles