Skip to main content

Express middleware

Static Middleware

Middleware to serve Static Content

Symbolic Link acts as a shortcut that points to other dir on local machine

require.resolve applies node path resolving algorithm to find abs path of file

const packagePath = require.resolve("local-client/build/index.html");
app.use(express.static(path.dirname(packagePath)))

path.dirname() is used to return the path leading up to dir folder excluding the file itself

express.static does not work well with symbolic links

References

  1. app.use() ↔ to use Express middleware