Request forwarding to external URLs and cors

Skip to first unread message

Krishnaprasad Subbarao

Jun 17, 2021, 12:02:08 AM6/17/21
to LoopbackJS
Hi, We are working on a nodeJS/loopback application which has few REST APIs to do some CRUD operations. This application also needs to forward requests to external URLs identified at runtime based on a user requests and the data added by CRUD operations. The CRUD operations need authentication and authorization. Where as the requests to be forwarded do not need this support. One of the approach to implement this application I could think off is
i) Implement global interceptors for Authentication, authorization as global interceptors
ii) Controllers, services for CRUD operations on URI /data and apply authentication and authorization on this.
iii) Implement a local interceptor for a controller for particular URI say /forward to invoke middleware provided by node module http-proxy-middleware, to forward the requests to external URLs with headers and body.

Is this a good solution for this problem? What could be a better approach?
How to avoid authentication interceptors getting invoked for requests beling forwarded
Do we need to do any additional to avoid CORS issues as cors is the first middleware called in the sequence

Sharing the sample code as an attachment


Raymond Feng

Jun 17, 2021, 1:11:35 AM6/17/21
to LoopbackJS
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
To view this discussion on the web visit

Reply all
Reply to author
0 new messages