You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some of my website's HTTP requests are failing only in the Cypress browser (e.g. signing up for a new account). After debugging, it was discovered this was due to the response header returning a different content-type in the Cypress browser.
Chrome browser:
content-type: application/json
Cypress browser (not running headlessly):
Content-type: application/json; charset=utf-8
Cypress is adding "charset=utf-8" to the content-type.
Desired behavior:
Return the same content-type as the Chrome browser.
changed the title [-]Cypress browser is adding "charset=utf-8" to the content-type in the response header[/-][+]Cypress browser adds "charset=utf-8" to the content-type in the response header[/+]on Mar 5, 2019
changed the title [-]Cypress browser adds "charset=utf-8" to the content-type in the response header[/-][+]Chrome Cypress browser adds "charset=utf-8" to the content-type in the response header[/+]on Mar 7, 2019
I also encountered the same problem. Previously my app checks the Content-Type of the http response by doing a string comparison which fails. I refactored it so it checks the existence of the desired type instead:
In my case strange is that,
when running test on locally deployed (localhost) web page, the header is unchanged: application/json
But when testing the same web app remotely deployed (s3 + CloudFront), the header is extended with charset=utf-8
This is a symptom of ExpressJS (which Cypress uses for the internal proxy server) forcing charset=utf-8 on all responses, which will be fixed by #4698.
Activity
[-]Cypress browser is adding "charset=utf-8" to the content-type in the response header[/-][+]Cypress browser adds "charset=utf-8" to the content-type in the response header[/+][-]Cypress browser adds "charset=utf-8" to the content-type in the response header[/-][+]Chrome Cypress browser adds "charset=utf-8" to the content-type in the response header[/+]yusinto commentedon Apr 2, 2019
I also encountered the same problem. Previously my app checks the Content-Type of the http response by doing a string comparison which fails. I refactored it so it checks the existence of the desired type instead:
I don't think you can always safely assume that browsers will only send 'application/json' in the Content-Type header. Hope that helps.
funatronics commentedon Apr 10, 2019
@yusinto yeah, that was my solution to this problem as well.
ludwikd commentedon May 31, 2019
In my case strange is that,
when running test on locally deployed (localhost) web page, the header is unchanged:
application/json
But when testing the same web app remotely deployed (s3 + CloudFront), the header is extended with
charset=utf-8
flotwig commentedon Jul 12, 2019
This is a symptom of ExpressJS (which Cypress uses for the internal proxy server) forcing
charset=utf-8
on all responses, which will be fixed by #4698.12 remaining items