3

How can I access the express app instance within a LoopBack 4 application to add a middlware such as helmet or compression via app.use()?

nflaig
  • 673
  • 1
  • 8
  • 15

2 Answers2

1

LoopBack 4 does not have a first-class support for Express middleware yet, please join the discussion in the following GitHub issue:

Our current recommendation is to create a top-level Express application (where you can mount middleware like helmet) and then mount the LoopBack4 application as a sub-component. You can learn more in the following tutorial:

Miroslav Bajtoš
  • 10,667
  • 1
  • 41
  • 99
1

Since the previous answer, LoopBack 4 has provided support for Express.js middleware support alongside the existing LoopBack 4 middleware:

This includes additional features that enable integration with the Context for dependency injection, wrapping the middleware in a factory function for dynamic configuration, and using it as an interceptor.

Rifa Achrinza
  • 1,555
  • 9
  • 19