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
Replies: 2 comments
-
|
Beta Was this translation helpful? Give feedback.
-
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)); |
Beta Was this translation helpful? Give feedback.
-
Such as the title
Beta Was this translation helpful? Give feedback.
All reactions