I'm trying to make an extension that opens a bitly URL and fetches the title:
http://bit[dot]ly/30YbIyD
Postman follows the redirects and gets the resulting document for me.
When I try with Axios I get empty response data although the redirection seems to happen.
The first request receives a 301 pointing to "stackoverflow.com". In that request, we get "200 SUCCESS" however the data part is empty.
axios({
'url': 'http://bit[dot]ly/30YbIyD',
method: 'get',
maxRedirects: 5,
headers: {
'Content-Type': 'text/html',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET',
},
withCredentials: true,
})
.then((res) => {
console.log("Response", res)
})
.catch((err) => {
console.log("Error with fetch: ", err)
});
There are no error messages, but I was expecting to see the same result as Postman returns; the final document.
I also get these warnings in my browser console:
Cross-Origin Read Blocking (CORB) blocked cross-origin response <URL> with MIME type text/html. See <URL> for more details.
and
A cookie associated with a cross-site resource at http://bit.ly/ was set without the
SameSite
attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set withSameSite=None
andSecure
. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.
Here are the headers Postman sends: https://i.stack.imgur.com/4pYc1.jpg