Skip to content

Include options with router function #662

@paustint

Description

@paustint

Describe the feature you'd love to see

I have been struggling implementing my use-case and wanted to explain what my needs are to see if there are any thoughts on approaching this differently and have also proposed some minor changes that would help me solve my use-case.

Use Case:
The target system I am proxying has many different domains that are user-configurable, so my users choose which instance they want to work with, and based on this I need to determine which URL to redirect them to.

I also need to set some headers (oauth token) that I have stored in my DB to authenticate with the target system.

I need to query the DB to get the target URL and to get the auth token to add to the headers. I have to perform the DB query twice - once in router and again in onProxyReq, and I would prefer to query just once.

Ideally, I would be able to do one of the following:

  1. Have access to options in router so I could update things like options.headers
  2. Have access to res in router so I could gain access to res.locals (this is express specific)
  3. Ability to set the target in onProxyReq where I have full context of everything I would need to do all the work with 1 DB query

Additional context (optional)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions