Invalid character in header content ["x-cypress-file-path"] in Cypress

267 views Asked by At

I have some strange issue in Cypress. When I go to the Cypress automation toll, click Settings and then try to click Project settings, I get the following error:

Invalid character in header content ["x-cypress-file-path"] TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["x-cypress-file-path"] at ServerResponse.setHeader (node:_http_outgoing:666:3) at j (:4526:1236) at Server. (:4526:1875) at Server.emit (node:events:513:28) at parserOnIncoming (node:_http_server:1072:12) at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17)

My Cypress version in 13.3.3 (the last one) but the issue appears in the oldest versions as well. Here is the screenshot of the problem. What could be the issue?

enter image description here

I have tried to use different versions of Cypress. I expect to resolve the issue and be able to click see Project settings.

1

There are 1 answers

2
Aladin Spaz On

This may be a problem in the configuration file cypress.config.js, specifically the fileServerFolder - root project folder setting.

This is used when the Cypress proxy handles a response, using this code:

const args = _.compact([
  fileServerFolder,            // from config 
  req.url,                     // from request
])

const file = decodeURI(url.parse(path.join(...args)).pathname)

res.setHeader('x-cypress-file-path', file)   // error occurs here

The other external value is the request URL, which you can check in the Network tab of devtools for anything suspicious (i.e odd characters)