Closed danbord closed 5 years ago
Ok I found the issue. Seems like when using release manager the Environment variable is not taken into consideration. I had to add a powershell script Task in my release :
Set-Item Env:NODE_TLS_REJECT_UNAUTHORIZED 0
Interesting. I'm using Azure Devops at work too. I use the release variables to set the required environment variables for node and cypress, works fine.
How could this be set within the package.json file? (I am new).
Hi @MSIH , given that you are on Windows, you could do this in package.json: "unsafe-cypress-ntlm": "set NODE_TLS_REJECT_UNAUTHORIZED=0 && npm run cypress-ntlm"
But please, go through the tips here and try to resolve the root cause - completely disabling TLS validation for node is pretty bad for security.
i have same 504 issue i have set "cypress-ntlm": "set NODE_TLS_REJECT_UNAUTHORIZED=0 && npm run ntlm-proxy && (cypress-ntlm open & ntlm-proxy-exit)",
We received this error at the network level:
> Error: Error establishing proxy connection. Response from server was: HTTP/1.1 504 Unknown Host
Date: Fri, 15 Nov 2019 14:32:04 GMT
Via: 1.1 proxy.localdomain
Cache-Control: no-store
Content-Type: text/html
Content-Language: en
Content-Length: 666
Hi @spham - I have opened a new issue #87 where we can discuss this.
For some reasons, adding directly set NODE_TLS_REJECT_UNAUTHORIZED=0 &&
in the scripts
section of my package.json didn't work… It only works if I add it in .bat
file and if I call it.
In env.bat
I have:
set NODE_TLS_REJECT_UNAUTHORIZED=0
And in package.json
I have:
"scripts": {
"ntlm-proxy": "start /min \"ntlm-proxy\" cmd /c \"node_modules\\.bin\\ntlm-proxy\"",
"test": "env.bat && npm run ntlm-proxy && (cypress-ntlm open & ntlm-proxy-exit)"
}
I tried to use NODE_EXTRA_CA_CERTS
but no luck… I exported the SSL certificate of my website (see below how to proceed with Windows 10):
Then I tried set NODE_EXTRA_CA_CERTS=C:\path\to\file.cer
in the console before running npm run test
, but then I still get the same 504 Gateway Timeout. I searched to convert the .cer
file to .pem
but it seems to be the same data… If someone has some tips regarding how to use NODE_EXTRA_CA_CERTS
, then it would be appreciated 👍
Hi @Aymkdn - odd that you can't set the environment variable directly in the scripts section, but good that you found a workaround.
As for adding CA certificates to Node, please note that you should add the CA certificate, not the website certificate. The CA certificate is the public part of the certificate used to create the website certificate (or an intermediate certificate). Follow your described steps, but add the following between 3 and 4:
As for the format - .pem is actually called .cer on windows, so you have the right format.
When I run the test (headless mode) on my server it is working well.
When I run them from Azure Devops Release it doesn't. I'm using the same user.
All my cy.visit() end up with 504 Gateway Timeout error.
cy.request() also result in a 504 but gave some more details containing PROXY_TO_SERVER_REQUEST_ERROR
That lead me to a post in node-http-mitm-proxy: https://github.com/joeferner/node-http-mitm-proxy/issues/60
My NODE_TLS_REJECT_UNAUTHORIZED = 0 is in my Global and User variables.
Don't know what else can I try :/