How to maintain auth in a test and avoid a 401?

I’m trying to sign into my company’s new app using K6. I can sign in fine, but when it hits the redirect to the landing page, I get a 302. I wasn’t too concerned about that, since I can just add a GET request to the landing page and it would be fine. However, when I add that GET in, I get a 401 back.

I’m not really sure what to add in to prevent this error: cookies appear to be maintained internally by K6, I’m using all of the right headers and values, and within the same test I am getting a successful login.

I’m fairly new to testing, so I figure this is an easily solved error and I’m just missing something. Thanks!

I’m not sure exactly what the issue is, you’d probably have to paste some (suitably anonymized) code and explain precisely what doesn’t work, but k6 should follow redirects by default. Unless you have manually set the maxRedirects option to 1?

I set maxRedirects to 10, so that shouldn’t be it.

When I submit a POST request to sign into my website, it’s supposed to redirect to a landing page. Instead of redirecting, however, I just get an HTTP 302. I was able to get a partial fix by just tacking the GET for where it’s supposed to go after.

I’m going to go ahead and close this, though: One, the 401 error I was getting was solved for, and replaying a HAR recording of a functioning redirect in the browser gets the same result I got trying to do a GET directly after, so I would guess there’s no other way to do this, and there’s nothing about having to do it this way that invalidates my tests. Thanks though!