How do I add a referer to an HTTP request? I added it directly in the request header and it doesn't seem to work. #1815
Unanswered
2394024600
asked this question in
Q&A
Replies: 2 comments
|
TL;DR:
This is because when a script is executed from a webpage, the requests initiated directly by the webpage itself (e.g., through JavaScript like To set a custom header with a background script, you can use something like: fetch('https://api.example.com/endpoint', {
method: 'POST',
headers: {
'Authorization': 'Bearer your-token',
'Custom-Header': 'CustomHeaderValue'
},
body: JSON.stringify({
key: 'value'
})
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error)); |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
Such as the title
All reactions