I have a website in which the login is done with Clerk. When trying to test it with Cypress, I face the issue that my login page returns 401.
When testing it in an incognito window, I see that right after the 401, it does another request which then gets redirected and succeeds.
The response headers are:
HTTP/1.1 401 Unauthorized
content-type: text/html
x-clerk-auth-reason: uat-missing
x-clerk-auth-status: interstitial
Vary: Accept-Encoding
Content-Encoding: gzip
Date: Tue, 20 Feb 2024 23:34:13 GMT
Connection: keep-alive
Keep-Alive: timeout=5
Transfer-Encoding: chunked
After searching for the x-clerk-auth-reason: uat-missing
response header, I haven't found anything in Google or the Clerk.com docs.
Then, checking further requests, I saw that they include the cookie __client_uat=0
, so I have tried it, and it works! Now I am making my request:
cy.visit('/my-login-page', {
headers: {
'Cookie': '__client_uat=0'
}
});
I guess this is just the case for Clerk development applications.
I hope this helps somebody in the future! :)