Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom request headers when fetching external URL resources #870

Open
megamattzilla opened this issue Sep 12, 2024 · 0 comments
Open
Labels
enhancement New feature or request untriaged Issue needs to be reviewed for validity

Comments

@megamattzilla
Copy link

When AS3 fetches remote URL resources, customers need a way to specify custom HTTP request headers on the GET request.

Describe the solution you'd like:

When specifying any external URL reference, add schema so that custom HTTP request header name and values can be specified.

For example, in order for AS3 to fetch resources from githubs REST API endpoint api.github.com, the request header "Accept: application/vnd.github.raw+json" must be specified.

Example AS3 Schema:

{
    "exampleWAF": {
        "class": "WAF_Policy",
        "url": {
            "url": "https://api.github.com/repos/user/coolrepo/waf_policy.xml",
            "extra-headers": [
                {
                    "Accept": "application/vnd.github.raw+json"
                }
            ]
        }
    }
}

Ideally:

  • n-number HTTP request header name/values using an item array
  • specified per URL reference if some URLs need special headers and others don't

Currently, there is no easy way to add this to the GET request when AS3 fetches the resource. I found that I could modify /var/config/rest/iapps/f5-appsvcs/lib/util/util.js file on Big-IP to hard-code extra request headers, but this is global, messy, and unsupported.

((Fun fact)) the modification is adding these 3 lines and restarting restnoded:

           if (typeof opts.headers['Accept'] !== 'string') {
               opts.headers['Accept'] = 'application/vnd.github.raw+json';
           }

After that, i am able to fetch files from github REST API.

@megamattzilla megamattzilla added enhancement New feature or request untriaged Issue needs to be reviewed for validity labels Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request untriaged Issue needs to be reviewed for validity
Projects
None yet
Development

No branches or pull requests

1 participant