fetch not return complete response headers

Created on 6 May 2016  路  3Comments  路  Source: github/fetch

I can only get content type header.

I use other client like axios, it contains all headers like date etc.

I'm calling from chrome extension, any thoughts? thanks.

Most helpful comment

@naivefun, I'm sure you've figured it out by now, but for anyone else with the same issue - it's likely because your CORS headers aren't set correctly on the server.

If you're using, say, koa-cors, your config might look something like this:

app.use(koaCors({
  origin: true,
  credentials: true,
  expose: ['Some-Custom-Header'], // <-- this is what you need
}));

All 3 comments

How are you verifying which of the headers are you getting back? It seems strange that you can only access a single response header. Can you show us some example code?

Also, keep in mind that if you're using Chrome, you're not using this polyfill. Chrome has its own native implementation of fetch, so if there's a bug in it, we can't help.

@naivefun, I'm sure you've figured it out by now, but for anyone else with the same issue - it's likely because your CORS headers aren't set correctly on the server.

If you're using, say, koa-cors, your config might look something like this:

app.use(koaCors({
  origin: true,
  credentials: true,
  expose: ['Some-Custom-Header'], // <-- this is what you need
}));

I also had this problem. Turns out it for me was CORS also, as @leebenson mentioned could be a reason.

I am using .NET Core and had to add

 app.UseCors(builder => builder.AllowAnyOrigin()
       .WithExposedHeaders("Content-Disposition") <---- this
  );
Was this page helpful?
0 / 5 - 0 ratings

Related issues

indranildutta06 picture indranildutta06  路  3Comments

fczuardi picture fczuardi  路  3Comments

shirotech picture shirotech  路  3Comments

karladler picture karladler  路  4Comments

codeashian picture codeashian  路  3Comments