Middleware sequence: how to use it with helmet extension?

Skip to first unread message

Tamas Geschitz

Mar 1, 2021, 5:30:11 PM3/1/21
to LoopbackJS

I would like to add HelmetJS to my app. I found this extension:


However, this uses the old Action sequence. I don't see how can I make this work with the Middleware sequence, since it requires dependency injection, which I can't use in middleware.

There are other extensions like this one (using the old syntax). Could somebody explain to me how to migrate such extensions to the middleware syntax?

Thanks in advance



Raymond Feng

Mar 1, 2021, 5:37:20 PM3/1/21
to LoopbackJS
You can simply add the following to your Application class’s constrcutor:



You received this message because you are subscribed to the Google Groups "LoopbackJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to loopbackjs+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/loopbackjs/2963543f-5daf-4ede-8ea8-b228292ff1e9n%40googlegroups.com.

Tamas Geschitz

Mar 2, 2021, 5:01:07 AM3/2/21
to LoopbackJS
Hi Raymond!

Thanks for getting back to me.

This works only with the default settings, like this


as soon as your define any options like helmet(options) or you try to use individual middleware like helmet.dnsPrefetchControl(options), you get 500 error:

      failed with status code 500. TypeError: Cannot read property 'setHeader' of undefined
    failed with status code 500. TypeError: Cannot read property 'removeHeader' of undefined

This is coming form one of the helmet middleware.

Is there any way to fix this? I need to configure helmet, can't just rely on the default options. 

Raymond Feng

Mar 2, 2021, 10:12:20 AM3/2/21
to LoopbackJS

MP Modise

Mar 2, 2021, 11:19:37 PM3/2/21
to loopb...@googlegroups.com
You welcome to join Slack community for quicker response turn around 

Tamas Geschitz

Mar 3, 2021, 3:20:27 AM3/3/21
to LoopbackJS
Thanks Raymond! It works fine now. 

There is even a slack group? Perfect, I didn't know.


Mar 3, 2021, 5:58:48 PM3/3/21
to loopb...@googlegroups.com
Thank you !

Ce mail est à l’attention exclusive des destinataires désignés. Il peut contenir des informations confidentielles. 

Si vous le recevez par erreur, merci de le détruire et d’en informer sans délais l’expéditeur. 

Le contenu de ce mail ne pourrait engager la responsabilité de l’Université Alioune DIOP de Bambey que s’il a été émis par une personne dûment habilitée, agissant dans le cadre strict des fonctions auxquelles elle est employée et à des fins non étrangères à ses attributions. 

Toute diffusion, copie, publication partielle ou totale, ou toute autre utilisation est interdite, sauf autorisation. 

Reply all
Reply to author
0 new messages