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

Feature Request: Add x-forward-header-* support for custom header forwarding #1172

Open
dudosxdev opened this issue Mar 22, 2025 · 2 comments

Comments

@dudosxdev
Copy link

It would be valuable to have the ability to forward custom HTTP headers to target URLs through the Reader API. This would allow accessing content that requires specific authentication or custom headers.

@nomagick
Copy link
Member

Hi @dudosxdev ,

Because Reader very much follows the usage pattern of a browser, it would be preferred to add these headers from within the page javascript.

Maybe except for the Authorization header. Are you intending to add a custom Authorization headed to the request?

Also, it could mean differently, by "forwarding custom headers".

Do you wish to:

  1. only forward specific headers to the exact URL you intend to access
  2. forward headers in all the requests of the origin of the URL you intend to access
  3. forward headers in all the requests the browser will ever send

@dudosxdev
Copy link
Author

I understand your points, however, consider a slightly broader scenario for header forwarding.

Here's an example of what I had in mind:

curl https://r.jina.ai/ \
  -H "Accept: text/event-stream" \
  -H "X-Respond-With: readerlm-v2" \
  -H "X-Forward-Header-User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:135.0) Gecko/20100101 Firefox/135.0" \
  -H "X-Forward-Header-Accept-Language: en-US,en;q=0.5" \
  -H "X-Forward-Header-Authorization: Bearer sample-token" \
  -H "X-Forward-Header-X-CSRF: sample-csrf-token" \
  -d @- <<EOFEOF
{
  "url": "https://www.samsung.com/us/smartphones/galaxy-s25-ultra/buy/galaxy-s25-ultra-1tb-unlocked-sm-s938uakfxaa/",
  "jsonSchema": {
    "type": "Object",
    "ram": "str",
    "rom": "str",
    "front_camera": "str",
    "back_camera": "str"
  },
  "instruction": "Extract detailed phone specifications from the webpage as structured JSON."
}
EOFEOF

In this example, the target URL would receive headers such as these:

User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:135.0) Gecko/20100101 Firefox/135.0
Accept-Language: en-US,en;q=0.5
Authorization: Bearer sample-token
X-CSRF: sample-csrf-token

Implementing such an approach would help users flexibly pass along required headers to target services

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants