Passing custom request headers to Loopback

How to pass custom request headers (X-TRANSACTION-ID, X_USER_ID) to loopback for POST API. We have part of the headers in the data source file. But how can I make it dynamic? I am using a remote method. Adding headers to the request to the context object does not seem to matter. Only if headers are added to the data source file do they seem to have an effect.

+7
loopback strongloop
source share
1 answer

for a related model, in a .js file, you can use beforeRemote to modify the request before executing the remote method.

the context object (ctx) has access to both the request and the response. For example: you must have access to the request body using ctx.req.body

0
source share

All Articles